diff options
| author | Teddy Wing | 2018-03-14 18:53:28 +0100 | 
|---|---|---|
| committer | Luc Donnet | 2018-03-23 17:16:43 +0100 | 
| commit | 55b6ea26f7f8d40d7227bacbbe63951ec77a39e1 (patch) | |
| tree | 7b075dbf7225e7b1c36907c28bb84a8dcf4eb4bb | |
| parent | 012e1650b1dd0f6a29d68a114f195cb529686080 (diff) | |
| download | chouette-core-55b6ea26f7f8d40d7227bacbbe63951ec77a39e1.tar.bz2 | |
Routes: Add `/costs` route
Render the `costs` field of a `Chouette::Route` as JSON. This lives at:
http://stif-boiv.dev:3000/referentials/4/lines/1857/routes/7/costs.json
I want this in order to get the distance & time costs of a route so that
I can merge them with `JourneyPattern#costs` on the frontend on
`JourneyPatternsCollection#show`.
Refs #6203
| -rw-r--r-- | app/controllers/routes_controller.rb | 4 | ||||
| -rw-r--r-- | app/views/routes/costs.rabl | 2 | ||||
| -rw-r--r-- | config/routes.rb | 1 | 
3 files changed, 7 insertions, 0 deletions
| diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index af5a9a91b..418ba3751 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -70,6 +70,10 @@ class RoutesController < ChouetteController      redirect_to referential_line_path(@referential, route.line)    end +  def costs +    @route = resource +  end +    protected    alias_method :route, :resource diff --git a/app/views/routes/costs.rabl b/app/views/routes/costs.rabl new file mode 100644 index 000000000..d4465d03e --- /dev/null +++ b/app/views/routes/costs.rabl @@ -0,0 +1,2 @@ +object @route +attributes :costs diff --git a/config/routes.rb b/config/routes.rb index 6313b5678..25105241a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,7 @@ ChouetteIhm::Application.routes.draw do          member do            get 'edit_boarding_alighting'            put 'save_boarding_alighting' +          get 'costs'            post 'duplicate', to: 'routes#duplicate'          end          resource :journey_patterns_collection, :only => [:show, :update] | 
