aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Peignier2016-11-30 14:18:38 +0100
committerAlban Peignier2016-11-30 14:18:38 +0100
commit4da93097eebcb42624a09970910b1b64b0877ead (patch)
tree88901a9772c1d493da143b96339072c2ba41b069
parentac92d7020fe98f43381fc896a5c499e0029c7ac8 (diff)
downloadchouette-core-4da93097eebcb42624a09970910b1b64b0877ead.tar.bz2
Add StopArea#user_objectid in json used by routes/_form. Refs #2127
-rw-r--r--app/helpers/routes_helper.rb2
-rw-r--r--app/models/chouette/stop_area.rb8
-rw-r--r--app/views/autocomplete_stop_areas/index.rabl3
3 files changed, 11 insertions, 2 deletions
diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb
index 99278625d..d4cadcd5a 100644
--- a/app/helpers/routes_helper.rb
+++ b/app/helpers/routes_helper.rb
@@ -15,7 +15,7 @@ module RoutesHelper
def route_json_for_edit(route)
route.stop_points.includes(:stop_area).map do |stop_point|
- stop_area_attributes = stop_point.stop_area.attributes.slice("name","city_name", "zip_code")
+ stop_area_attributes = stop_point.stop_area.attributes.slice("name","city_name", "zip_code", "user_objectid")
stop_point_attributes = stop_point.attributes.slice("for_boarding","for_alighting")
stop_area_attributes.merge(stop_point_attributes).merge(stoppoint_id: stop_point.id, stoparea_id: stop_point.stop_area.id)
end.to_json
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb
index 815304cca..50fe18f64 100644
--- a/app/models/chouette/stop_area.rb
+++ b/app/models/chouette/stop_area.rb
@@ -83,6 +83,14 @@ class Chouette::StopArea < Chouette::ActiveRecord
end
end
+ def user_objectid
+ if objectid =~ /^.*:([0-9A-Za-z_-]+):STIF$/
+ $1
+ else
+ id.to_s
+ end
+ end
+
def children_in_depth
return [] if self.children.empty?
diff --git a/app/views/autocomplete_stop_areas/index.rabl b/app/views/autocomplete_stop_areas/index.rabl
index 6d81442c7..adec16cff 100644
--- a/app/views/autocomplete_stop_areas/index.rabl
+++ b/app/views/autocomplete_stop_areas/index.rabl
@@ -9,7 +9,8 @@ node do |stop_area|
:short_name => truncate(stop_area.name, :length => 30) || "",
:zip_code => stop_area.zip_code || "",
:city_name => stop_area.city_name || "",
- :short_city_name => truncate(stop_area.city_name, :length => 15) || ""
+ :short_city_name => truncate(stop_area.city_name, :length => 15) || "",
+ :user_objectid => stop_area.user_objectid
}
end