Organisations can now have a detailed place name and address, plus a specific geocoded localisation. Refs #71
This commit is contained in:
parent
2030a7c0ce
commit
77ba9032d3
@ -1,6 +1,6 @@
|
||||
# Setting up OpenStreeMap from a generic #map element
|
||||
$(document).ready ->
|
||||
$('#map.events').each ->
|
||||
$('#map.events, #map.orgas').each ->
|
||||
map = L.map 'map'
|
||||
|
||||
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
@ -26,9 +26,9 @@ $(document).ready ->
|
||||
# Automatic focus to all displayed events
|
||||
map.fitBounds layer.getBounds()
|
||||
else
|
||||
$('#map.events').remove()
|
||||
$('#map.events, #map.orgas').remove()
|
||||
|
||||
$('#map.event').each ->
|
||||
$('#map.event, #map.orga').each ->
|
||||
coord = [$(this).data('latitude'), $(this).data('longitude')]
|
||||
|
||||
map = L.map('map').setView [coord[0], coord[1]], 16
|
||||
|
@ -55,11 +55,11 @@
|
||||
.field.description label:before
|
||||
content: $fa-var-pencil-square-o
|
||||
.field.place_name label:before
|
||||
content: $fa-var-flag
|
||||
content: $fa-var-map-pin
|
||||
.field.address label:before
|
||||
content: $fa-var-map-marker
|
||||
.field.city label:before, th.city a:before
|
||||
content: $fa-var-compress
|
||||
content: $fa-var-building-o
|
||||
.field.department label:before, th.department a:before
|
||||
content: $fa-var-puzzle-piece
|
||||
.field.region label:before, th.region a:before
|
||||
|
@ -11,7 +11,7 @@
|
||||
/* Popup are better displayed with this: */
|
||||
max-width: initial
|
||||
|
||||
&.event
|
||||
&.event, &.orga
|
||||
height: 20em
|
||||
|
||||
.tags #map
|
||||
|
@ -89,9 +89,9 @@ class OrgasController < ApplicationController
|
||||
# through
|
||||
def orga_params
|
||||
params.require(:orga)
|
||||
.permit :lock_version, :kind_id, :name, :description, :city,
|
||||
:department, :region_id, :url, :diaspora, :feed, :contact,
|
||||
:submitter, :tags, :active
|
||||
.permit :lock_version, :kind_id, :name, :description, :place_name,
|
||||
:address, :city, :department, :region_id, :url, :diaspora,
|
||||
:feed, :contact, :submitter, :tags, :active
|
||||
end
|
||||
|
||||
# Check that you can only edit an existing event if you know its secret
|
||||
|
@ -5,9 +5,10 @@ module OrgasHelper
|
||||
description: strip_tags(@orga.description),
|
||||
DC: { title: @orga.name },
|
||||
geo: {
|
||||
region: @orga.region,
|
||||
placename: @orga.city,
|
||||
position: "#{@orga.city.try :latitude}; #{@orga.city.try :longitude}"
|
||||
region: @orga.region,
|
||||
position: "#{@orga.latitude};#{@orga.longitude}",
|
||||
ICBM: "#{@orga.latitude}, #{@orga.longitude}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -97,9 +97,7 @@ class Event < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def full_address
|
||||
# Temporary solution until OSM reverse geocoding can use the new regions
|
||||
# [address, city, region.try(:name)].compact.join ', '
|
||||
[address, city].compact.join ', '
|
||||
[address, city, region.try(:name)].compact.join ', '
|
||||
end
|
||||
|
||||
def hashtags
|
||||
|
@ -15,6 +15,10 @@ class Orga < ActiveRecord::Base
|
||||
validates :contact, allow_blank: true, email: true
|
||||
validates :submitter, allow_blank: true, email: true
|
||||
|
||||
geocoded_by :full_address
|
||||
# after_validation :geocode, if: -> (obj) { obj.address_changed? }
|
||||
after_validation :geocode
|
||||
|
||||
scope :active, -> { where active: true }
|
||||
scope :moderated, -> { where moderated: true }
|
||||
scope :unmoderated, -> { where moderated: false }
|
||||
@ -56,6 +60,10 @@ class Orga < ActiveRecord::Base
|
||||
name.gsub(/\AL'/, '').gsub(/[\s\*']/, '-').delete ':'
|
||||
end
|
||||
|
||||
def full_address
|
||||
[address, city, region.try(:name)].compact.join ', '
|
||||
end
|
||||
|
||||
def to_s
|
||||
"[#{kind.name}] #{name}"
|
||||
end
|
||||
|
@ -21,6 +21,15 @@
|
||||
.field.description
|
||||
= f.label :description
|
||||
= f.text_area :description, rows: 25, class: :description
|
||||
.field.place_name
|
||||
= f.label :place_name
|
||||
= f.text_field :place_name
|
||||
.field.address
|
||||
.helper
|
||||
:markdown
|
||||
#{t '.address_helper'}
|
||||
= f.label :address
|
||||
= f.text_field :address
|
||||
.field.city
|
||||
= f.label :city
|
||||
= f.text_field :city, list: :cities
|
||||
|
@ -58,6 +58,20 @@
|
||||
%em.fa.fa-lg.fa-thumbs-down
|
||||
= t '.cancel'
|
||||
|
||||
%p.full_address
|
||||
- if @orga.place_name.present?
|
||||
%span= @orga.place_name
|
||||
- if @orga.address.present?
|
||||
%span= @orga.address
|
||||
%span= link_to @orga.city,
|
||||
"http://fr.wikipedia.org/wiki/#{url_encode @orga.city}"
|
||||
%span= link_to @orga.region.try(:name),
|
||||
"http://fr.wikipedia.org/wiki/#{url_encode @orga.region.try :name}"
|
||||
|
||||
- if @orga.latitude && @orga.longitude
|
||||
.orga#map{ data: { url: "#{maps_path format: :json}",
|
||||
latitude: "#{@orga.latitude}", longitude: "#{@orga.longitude}" } }
|
||||
|
||||
%h3= t '.description'
|
||||
.description
|
||||
= description sanitize @orga.description,
|
||||
@ -65,21 +79,11 @@
|
||||
attributes: %w(href src width height style)
|
||||
|
||||
%dl
|
||||
- if @orga.city.present?
|
||||
%dt
|
||||
%em.fa.fa-compress
|
||||
= Orga.human_attribute_name :city
|
||||
%dd= @orga.city
|
||||
- if @orga.department.present?
|
||||
%dt
|
||||
%em.fa.fa-puzzle-piece
|
||||
= Orga.human_attribute_name :department
|
||||
%dd= @orga.department
|
||||
- if @orga.region.present?
|
||||
%dt
|
||||
%em.fa.fa-shield
|
||||
= Orga.human_attribute_name :region
|
||||
%dd= @orga.region
|
||||
- if @orga.url.present?
|
||||
%dt
|
||||
%em.fa.fa-external-link
|
||||
@ -123,7 +127,3 @@
|
||||
- if @events_future && @events_past.any?
|
||||
%dt= t '.past'
|
||||
%dd= t '.count', count: @events_past.count
|
||||
|
||||
.events#map{ title: @orga.name_as_tag,
|
||||
data: { url: maps_path(format: :json, tag: @orga.name_as_tag,
|
||||
future: false) } }
|
||||
|
@ -1,6 +1,8 @@
|
||||
=====================================================
|
||||
#{Orga.human_attribute_name(:kind).concat(':').ljust 12 } #{@orga.kind.name}
|
||||
#{Orga.human_attribute_name(:name).concat(':').ljust 12 } #{@orga.name}
|
||||
#{Orga.human_attribute_name(:place_name).concat(':').ljust 12 } #{@orga.place_name}
|
||||
#{Orga.human_attribute_name(:address).concat(':').ljust 12 } #{@orga.address}
|
||||
#{Orga.human_attribute_name(:city).concat(':').ljust 12 } #{@orga.city}
|
||||
#{Orga.human_attribute_name(:department).concat(':').ljust 12 } #{@orga.department}
|
||||
#{Orga.human_attribute_name(:region).concat(':').ljust 12 } #{@orga.region}
|
||||
|
@ -39,6 +39,8 @@ en:
|
||||
kind: Type
|
||||
name: Name
|
||||
description: Description
|
||||
place_name: Place name
|
||||
address: Address
|
||||
city: City
|
||||
department: Department
|
||||
region: Region
|
||||
|
@ -39,6 +39,8 @@ fr:
|
||||
kind: Type
|
||||
name: Nom
|
||||
description: Description
|
||||
place_name: Nom du lieu
|
||||
address: Adresse
|
||||
city: Ville
|
||||
department: Département
|
||||
region: Région
|
||||
|
@ -263,6 +263,9 @@ description plus complète."
|
||||
update:
|
||||
ok: L'organisation a été mise à jour
|
||||
form:
|
||||
address_helper: "*Associée à la ville et la région, elle générera une
|
||||
carte [OpenStreetMap](http://www.openstreetmap.org), affichée aux côtés
|
||||
de l'organisation*"
|
||||
url_helper: Lien vers le site web de l'organisation
|
||||
feed_helper: Lien **direct** vers un flux de syndication, type RSS ou atom
|
||||
contact_helper: Adresse e-mail de contact, affichée de manière peu
|
||||
|
9
db/migrate/20160409131029_add_place_name_to_orgas.rb
Normal file
9
db/migrate/20160409131029_add_place_name_to_orgas.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# Add more data to orgas, with an optionnal place name and address
|
||||
class AddPlaceNameToOrgas < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :orgas, :place_name, :text
|
||||
add_column :orgas, :address, :text
|
||||
add_column :orgas, :latitude, :float
|
||||
add_column :orgas, :longitude, :float
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160111124855) do
|
||||
ActiveRecord::Schema.define(version: 20160409131029) do
|
||||
|
||||
create_table "active_admin_comments", force: :cascade do |t|
|
||||
t.string "namespace", limit: 255
|
||||
@ -122,6 +122,10 @@ ActiveRecord::Schema.define(version: 20160111124855) do
|
||||
t.text "tags", default: ""
|
||||
t.text "diaspora"
|
||||
t.text "object_changes"
|
||||
t.text "place_name"
|
||||
t.text "address"
|
||||
t.float "latitude"
|
||||
t.float "longitude"
|
||||
end
|
||||
|
||||
add_index "orgas", ["kind_id"], name: "index_orgas_on_kind_id"
|
||||
|
@ -45,7 +45,7 @@ regions = {
|
||||
u'Corse' : 9,
|
||||
u'Île-de-France' : 12,
|
||||
u'Languedoc-Roussillon-Midi-Pyrénées' : 13,
|
||||
u'Nord-Pas-de-Calais-Picardie' : 17,
|
||||
u'Hauts-de-France' : 17,
|
||||
u'Provence-Alpes-Côte-d\'Azur' : 21,
|
||||
u'Pays de la Loire' : 18,
|
||||
u'Guadeloupe' : 23,
|
||||
|
Loading…
Reference in New Issue
Block a user