Léger nettoyage pour factoriser la recherche de ville

This commit is contained in:
echarp 2014-05-04 13:42:03 +02:00
parent 2404ea16b5
commit 3f5759ec87
5 changed files with 15 additions and 4 deletions

View File

@ -9,11 +9,11 @@ class MapsController < ApplicationController
@events = @events.where('start_time > ?', 360.days.ago).order :id
@cities_event = @events.collect { |event|
City.find_by_majname event.city.gsub('-', ' ').upcase
event.related_city
}.uniq.keep_if { |city| city }
@cities_lug = Lug.all.collect { |lug|
City.find_by_majname lug.city.gsub('-', ' ').upcase
lug.related_city
}.uniq.keep_if { |city| city }
end
end

View File

@ -32,4 +32,10 @@ class Event < ActiveRecord::Base
def same_day?
start_time.to_date == end_time.to_date
end
def related_city
if city.present?
City.find_by_majname city.gsub('-', ' ').upcase
end
end
end

View File

@ -1,3 +1,9 @@
class Lug < ActiveRecord::Base
belongs_to :region, foreign_key: 'region'
def related_city
if city.present?
City.find_by_majname city.gsub('-', ' ').upcase
end
end
end

View File

@ -28,7 +28,7 @@ xml.tag! 'rdf:RDF', 'xmlns:rdf' => "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xml.link event_url event
xml.tag! 'dc:identifier', "#{event.id}@agendadulibre.org"
xml.tag! 'dc:date', event.start_time
city = City.find_by_majname event.city.gsub('-', ' ').upcase
city = event.related_city
xml.tag! 'georss:point', "#{city.latitude} #{city.longitude}" rescue nil
@event = event

View File

@ -12,7 +12,6 @@
:coffee
marker = new OpenLayers.Marker(
new OpenLayers.LonLat(#{city.longitude}, #{city.latitude})
#new OpenLayers.Icon(<<iconURL>>, iconSize, iconOffset)
)
eventsLayer.addMarker marker