diff options
| author | Zog | 2017-12-20 17:48:17 +0100 |
|---|---|---|
| committer | Alban Peignier | 2017-12-21 21:35:02 +0100 |
| commit | e8285678efc9a62115fe0af4086c7a3959666bf8 (patch) | |
| tree | 64b18197dff4d6707be10bfccca9240c601ffded /app/controllers | |
| parent | 01b2d2b785d99c9b031269fc741b70ee9c248f16 (diff) | |
| download | chouette-core-e8285678efc9a62115fe0af4086c7a3959666bf8.tar.bz2 | |
Refs #5349 @1h; Deactivate StopAreas instead of destroying them5349-deactivate-stop-areas
- Update decorators (had to split `action_links` because of
`StopPointDecorator` inheriting from `StopAreaDecorator`)
- Add methods on model
- Add routes
- Add actions on controller (`Activatable` concern, shared with
`LinesController`)
- Add I18n keys
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/concerns/activatable.rb | 11 | ||||
| -rw-r--r-- | app/controllers/lines_controller.rb | 10 | ||||
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 3 |
3 files changed, 15 insertions, 9 deletions
diff --git a/app/controllers/concerns/activatable.rb b/app/controllers/concerns/activatable.rb new file mode 100644 index 000000000..1a34551a9 --- /dev/null +++ b/app/controllers/concerns/activatable.rb @@ -0,0 +1,11 @@ +module Activatable + extend ActiveSupport::Concern + + %w(activate deactivate).each do |action| + define_method action do + authorize resource, "#{action}?" + resource.send "#{action}!" + redirect_to request.referer || [current_referential, resource] + end + end +end diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index 676581076..f446e1d37 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -1,6 +1,8 @@ class LinesController < ChouetteController include ApplicationHelper + include Activatable include PolicyChecker + defaults :resource_class => Chouette::Line respond_to :html respond_to :xml @@ -50,14 +52,6 @@ class LinesController < ChouetteController super end - %w(activate deactivate).each do |action| - define_method action do - authorize resource, "#{action}?" - resource.send "#{action}!" - redirect_to request.referer || [resource.line_referential, resource] - end - end - # overwrite inherited resources to use delete instead of destroy # foreign keys will propagate deletion) def destroy_resource(object) diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 498493f1e..b478d38fa 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -1,6 +1,7 @@ class StopAreasController < ChouetteController include ApplicationHelper - + include Activatable + defaults :resource_class => Chouette::StopArea belongs_to :stop_area_referential |
