aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorZog2018-01-29 16:25:08 +0100
committercedricnjanga2018-02-06 11:10:18 -0800
commit47520607ee5a91fbba206aff4e72dd25293e1541 (patch)
tree803942f2337c581f3b663146922c57c38200d9ea /app/models
parent3c4e0b97d2c2502412817b5c99989f98821fc207 (diff)
downloadchouette-core-47520607ee5a91fbba206aff4e72dd25293e1541.tar.bz2
Refs #5758 @1h; Add localized names to StopAreas
Diffstat (limited to 'app/models')
-rw-r--r--app/models/chouette/stop_area.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb
index c6feaf940..bb8747faa 100644
--- a/app/models/chouette/stop_area.rb
+++ b/app/models/chouette/stop_area.rb
@@ -12,6 +12,8 @@ module Chouette
enumerize :area_type, in: Chouette::AreaType::ALL
enumerize :kind, in: %i(commercial non_commercial)
+ AVAILABLE_LOCALIZATIONS = %i(gb nl de fr it es)
+
with_options dependent: :destroy do |assoc|
assoc.has_many :stop_points
assoc.has_many :access_points
@@ -50,6 +52,11 @@ module Chouette
:nearest_topic_name, :comment, :long_lat_type, :zip_code, :city_name, :url, :time_zone]
end
+ def localized_names
+ val = read_attribute(:localized_names) || {}
+ Hash[*AVAILABLE_LOCALIZATIONS.map{|k| [k, val[k.to_s]]}.flatten]
+ end
+
def parent_area_type_must_be_greater
return unless self.parent