diff options
| author | Luc Donnet | 2016-11-14 21:15:31 +0100 |
|---|---|---|
| committer | Luc Donnet | 2016-11-14 21:15:31 +0100 |
| commit | 9cfa2309d53fa45342776f7cd2972080b3b85582 (patch) | |
| tree | aa435ae46f61fd25eee29a9e8a6c9beaf620a1d2 /app/controllers | |
| parent | 552611c5a96134eff8515bbfe32870e900225bfb (diff) | |
| parent | 3960264693d8ea79907b7c5619af678c69aef234 (diff) | |
| download | chouette-core-9cfa2309d53fa45342776f7cd2972080b3b85582.tar.bz2 | |
Merge branch 'master' of github.com:AF83/stif-boiv
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/api/v1/routes_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/clean_ups_controller.rb | 20 | ||||
| -rw-r--r-- | app/controllers/referential_companies_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/referential_group_of_lines_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/referential_networks_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/referentials_controller.rb | 6 | ||||
| -rw-r--r-- | app/controllers/routes_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 1 |
8 files changed, 16 insertions, 23 deletions
diff --git a/app/controllers/api/v1/routes_controller.rb b/app/controllers/api/v1/routes_controller.rb index e3694725f..fbc589355 100644 --- a/app/controllers/api/v1/routes_controller.rb +++ b/app/controllers/api/v1/routes_controller.rb @@ -3,11 +3,11 @@ class Api::V1::RoutesController < Api::V1::ChouetteController defaults :resource_class => Chouette::Route, :finder => :find_by_objectid! belongs_to :line, :parent_class => Chouette::Line, :optional => true, :finder => :find_by_objectid!, :param => :line_id - + protected def collection @routes ||= parent.routes - end + end end diff --git a/app/controllers/clean_ups_controller.rb b/app/controllers/clean_ups_controller.rb index 8718fc0dc..c6e4ecd44 100644 --- a/app/controllers/clean_ups_controller.rb +++ b/app/controllers/clean_ups_controller.rb @@ -1,23 +1,19 @@ class CleanUpsController < ChouetteController respond_to :html, :only => [:create] - belongs_to :referential def create - clean_up = CleanUp.new(params[:clean_up]) - - if clean_up.invalid? - flash[:alert] = clean_up.errors.full_messages.join("<br/>") + clean_up = CleanUp.new(clean_up_params) + clean_up.referential = @referential + if clean_up.valid? + clean_up.save else - begin - result = clean_up.clean - flash[:notice] = result.notice.join("<br/>") - rescue => e - Rails.logger.error "CleanUp failed : #{e} #{e.backtrace}" - flash[:alert] = t('clean_ups.failure', error_message: e.to_s) - end + flash[:alert] = clean_up.errors.full_messages.join("<br/>") end redirect_to referential_path(@referential) end + def clean_up_params + params.require(:clean_up).permit(:keep_lines, :keep_stops, :keep_companies, :keep_networks, :keep_group_of_lines, :expected_date) + end end diff --git a/app/controllers/referential_companies_controller.rb b/app/controllers/referential_companies_controller.rb index 104deba9f..a369488ba 100644 --- a/app/controllers/referential_companies_controller.rb +++ b/app/controllers/referential_companies_controller.rb @@ -27,7 +27,7 @@ class ReferentialCompaniesController < ChouetteController end def collection - @q = referential.companies.search(params[:q]) + @q = referential.workbench.companies.search(params[:q]) @companies ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page]) end diff --git a/app/controllers/referential_group_of_lines_controller.rb b/app/controllers/referential_group_of_lines_controller.rb index d40fd6090..4decef558 100644 --- a/app/controllers/referential_group_of_lines_controller.rb +++ b/app/controllers/referential_group_of_lines_controller.rb @@ -55,7 +55,7 @@ class ReferentialGroupOfLinesController < ChouetteController end def collection - @q = referential.group_of_lines.search(params[:q]) + @q = referential.workbench.group_of_lines.search(params[:q]) @group_of_lines ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page]) end diff --git a/app/controllers/referential_networks_controller.rb b/app/controllers/referential_networks_controller.rb index 2d3f4ad6b..00c680c65 100644 --- a/app/controllers/referential_networks_controller.rb +++ b/app/controllers/referential_networks_controller.rb @@ -35,7 +35,7 @@ class ReferentialNetworksController < ChouetteController end def collection - @q = referential.networks.search(params[:q]) + @q = referential.workbench.networks.search(params[:q]) @networks ||= @q.result(:distinct => true).order(:name).paginate(:page => params[:page]) end diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 3ae59f975..003c85d3a 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -57,11 +57,7 @@ class ReferentialsController < BreadcrumbController end def create_resource(referential) - if referential.created_from - referential.clone_association referential.created_from - else - referential.organisation = current_organisation - end + referential.organisation = current_organisation unless referential.created_from super end diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 59c129867..a7e8e32a6 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -77,7 +77,7 @@ class RoutesController < ChouetteController private def route_params - params.require(:route).permit( :direction_code, :wayback_code, :line_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, { stop_points_attributes: [ :id, :_destroy, :position, :stop_area_id, :for_boarding, :for_alighting ] } ) + params.require(:route).permit( :line_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, { stop_points_attributes: [ :id, :_destroy, :position, :stop_area_id, :for_boarding, :for_alighting ] } ) end end diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index 8f6a1565a..1f55b1de8 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -26,6 +26,7 @@ class StopAreasController < BreadcrumbController end def add_children + authorize stop_area @stop_area = stop_area @children = stop_area.children build_breadcrumb :edit |
