diff options
| author | Xinhui | 2017-02-07 16:34:11 +0100 |
|---|---|---|
| committer | Xinhui | 2017-02-07 16:34:25 +0100 |
| commit | 9424c83cec849002647cf7cd33809bc393cc2828 (patch) | |
| tree | 6e17937d4312e7a7227f75259e1eb83a7cfbc9c0 | |
| parent | d6263e5d304c19db9b0e491e3c338848276b2ebc (diff) | |
| download | chouette-core-9424c83cec849002647cf7cd33809bc393cc2828.tar.bz2 | |
Vehicle journeys #index format json
| -rw-r--r-- | app/controllers/vehicle_journeys_controller.rb | 2 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/index.rabl | 3 | ||||
| -rw-r--r-- | app/views/vehicle_journeys/show.rabl | 39 |
3 files changed, 43 insertions, 1 deletions
diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb index 3ae278ec1..45cb25344 100644 --- a/app/controllers/vehicle_journeys_controller.rb +++ b/app/controllers/vehicle_journeys_controller.rb @@ -1,6 +1,6 @@ class VehicleJourneysController < ChouetteController defaults :resource_class => Chouette::VehicleJourney - + respond_to :json, :only => :index respond_to :js, :only => [:select_journey_pattern, :edit, :new, :index] belongs_to :referential do diff --git a/app/views/vehicle_journeys/index.rabl b/app/views/vehicle_journeys/index.rabl new file mode 100644 index 000000000..eb042f7a9 --- /dev/null +++ b/app/views/vehicle_journeys/index.rabl @@ -0,0 +1,3 @@ +collection @vehicle_journeys + +extends "vehicle_journeys/show" diff --git a/app/views/vehicle_journeys/show.rabl b/app/views/vehicle_journeys/show.rabl new file mode 100644 index 000000000..09375f5d5 --- /dev/null +++ b/app/views/vehicle_journeys/show.rabl @@ -0,0 +1,39 @@ +object @vehicle_journey + +[ :objectid, :published_journey_name, :journey_pattern_id].each do |attr| + attributes attr, :unless => lambda { |m| m.send( attr).nil?} +end + +child(:time_tables) do |time_tables| + node do |tt| + [:objectid, :start_date, :end_date].map do |att| + node(att) { tt.send(att) } + end + node :calendar do |tt| + { + id: tt.calendar.id, + name: tt.calendar.name, + date_ranges: tt.calendar.date_ranges, + dates: tt.calendar.dates, + shared: tt.calendar.shared + } + end + end +end + +child :footnotes do |footnotes| + node do |footnote| + node(:id) { footnote.id } + end +end + +child :vehicle_journey_at_stops do |vehicle_stops| + node do |vehicle_stop| + node(:stop_area_object_id) { vehicle_stop.stop_point.stop_area.objectid } + [ :connecting_service_id, :arrival_time, :departure_time, :boarding_alighting_possibility].each do |attr| + node( attr) do + vehicle_stop.send(attr) + end unless vehicle_stop.send(attr).nil? + end + end +end |
