diff options
| author | Xinhui | 2017-06-28 17:20:23 +0200 |
|---|---|---|
| committer | Xinhui | 2017-06-28 17:20:23 +0200 |
| commit | bed9795be0bb85d7c8c311fe4ee0fb12e46832b4 (patch) | |
| tree | 18459aa9dcb81821a88f2acdf9ba72cee9be5616 /app/controllers | |
| parent | 641b1458236d2718a76ffaf0c04a5998623276bf (diff) | |
| parent | b260c832c8e129dbeacfe065d01bd0732dd80701 (diff) | |
| download | chouette-core-bed9795be0bb85d7c8c311fe4ee0fb12e46832b4.tar.bz2 | |
Merge branch 'master' into staging
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/calendars_controller.rb | 8 | ||||
| -rw-r--r-- | app/controllers/devise/cas_sessions_controller.rb | 10 | ||||
| -rw-r--r-- | app/controllers/lines_controller.rb | 5 | ||||
| -rw-r--r-- | app/controllers/referentials_controller.rb | 28 | ||||
| -rw-r--r-- | app/controllers/routes_controller.rb | 6 | ||||
| -rw-r--r-- | app/controllers/routing_constraint_zones_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 4 | ||||
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 18 |
8 files changed, 60 insertions, 23 deletions
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 86d567882..23af4129b 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -5,6 +5,12 @@ class CalendarsController < BreadcrumbController respond_to :html respond_to :js, only: :index + def show + show! do + @calendar = @calendar.decorate + end + end + private def calendar_params permitted_params = [:id, :name, :short_name, periods_attributes: [:id, :begin, :end, :_destroy], date_values_attributes: [:id, :value, :_destroy]] @@ -49,7 +55,7 @@ class CalendarsController < BreadcrumbController date << params[:q][key].to_i params[:q].delete(key) end - params[:q]['contains_date'] = Date.new(*date) + params[:q]['contains_date'] = Date.new(*date) rescue nil end end diff --git a/app/controllers/devise/cas_sessions_controller.rb b/app/controllers/devise/cas_sessions_controller.rb index 0a9d9ecb2..d000d0309 100644 --- a/app/controllers/devise/cas_sessions_controller.rb +++ b/app/controllers/devise/cas_sessions_controller.rb @@ -20,14 +20,14 @@ class Devise::CasSessionsController < Devise::SessionsController if LoginPolicy.new(current_user).boiv? redirect_to after_sign_in_path_for(current_user) else - redirect_to root_path, flash: {alert: t('devise.sessions.new.unauthorized')} + destroy message: t('devise.sessions.new.unauthorized') end end def unregistered end - def destroy + def destroy message: nil # if :cas_create_user is false a CAS session might be open but not signed_in # in such case we destroy the session here if signed_in?(resource_name) @@ -36,7 +36,11 @@ class Devise::CasSessionsController < Devise::SessionsController reset_session end - redirect_to(cas_logout_url) + if message + redirect_to(cas_logout_url, flash: {alert: message}) + else + redirect_to(cas_logout_url) + end end def single_sign_out diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index 7eedaeb05..1e2056aad 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -25,6 +25,11 @@ class LinesController < BreadcrumbController def show @group_of_lines = resource.group_of_lines show! do + @line = @line.decorate(context: { + line_referential: @line_referential, + current_organisation: current_organisation + }) + build_breadcrumb :show end end diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index aa5b359da..1239d512f 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -24,19 +24,21 @@ class ReferentialsController < BreadcrumbController end def show - resource.switch - show! do |format| - format.json { - render :json => { :lines_count => resource.lines.count, - :networks_count => resource.networks.count, - :vehicle_journeys_count => resource.vehicle_journeys.count + resource.vehicle_journey_frequencies.count, - :time_tables_count => resource.time_tables.count, - :referential_id => resource.id} - } - format.html { build_breadcrumb :show} - end - - @reflines = lines_collection.paginate(page: params[:page], per_page: 10) + resource.switch + show! do |format| + @referential = @referential.decorate + + format.json { + render :json => { :lines_count => resource.lines.count, + :networks_count => resource.networks.count, + :vehicle_journeys_count => resource.vehicle_journeys.count + resource.vehicle_journey_frequencies.count, + :time_tables_count => resource.time_tables.count, + :referential_id => resource.id} + } + format.html { build_breadcrumb :show} + end + + @reflines = lines_collection.paginate(page: params[:page], per_page: 10) end def edit diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 73febc4b9..786bd57cc 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -42,6 +42,12 @@ class RoutesController < ChouetteController end show! do + @route = @route.decorate(context: { + referential: @referential, + line: @line, + route_sp: @route_sp + }) + build_breadcrumb :show end end diff --git a/app/controllers/routing_constraint_zones_controller.rb b/app/controllers/routing_constraint_zones_controller.rb index 7707427b0..9d2fd712c 100644 --- a/app/controllers/routing_constraint_zones_controller.rb +++ b/app/controllers/routing_constraint_zones_controller.rb @@ -16,6 +16,10 @@ class RoutingConstraintZonesController < ChouetteController def show @routing_constraint_zone = collection.find(params[:id]) + @routing_constraint_zone = @routing_constraint_zone.decorate(context: { + referential: @referential, + line: @line + }) end protected diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 5c4552afb..3704f2885 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -14,6 +14,10 @@ class TimeTablesController < ChouetteController @year = params[:year] ? params[:year].to_i : Date.today.cwyear @time_table_combination = TimeTableCombination.new show! do + @time_table = @time_table.decorate(context: { + referential: @referential + }) + build_breadcrumb :show end end diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index ccd55965b..d03841356 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -11,11 +11,18 @@ class WorkbenchesController < BreadcrumbController scope = ransack_status(scope) # Ignore archived_at_not_null/archived_at_null managed by ransack_status scope - q_for_result = - scope.ransack(params[:q].merge(archived_at_not_null: nil, archived_at_null: nil)) - @wbench_refs = sort_result(q_for_result.result).paginate(page: params[:page], per_page: 30) + # We clone params[:q] so we can delete fake ransack filter arguments before calling search method, + # which will allow us to preserve params[:q] for sorting + ransack_params = params[:q].merge(archived_at_not_null: nil, archived_at_null: nil).clone + ransack_params.delete('associated_lines_id_eq') + + @q = scope.ransack(ransack_params) + @wbench_refs = sort_result(@q.result).paginate(page: params[:page], per_page: 30) + @wbench_refs = ModelDecorator.decorate( + @wbench_refs, + with: ReferentialDecorator + ) - @q = scope.ransack(params[:q]) show! do build_breadcrumb :show end @@ -33,7 +40,7 @@ class WorkbenchesController < BreadcrumbController private def resource - @workbench = Workbench.find params[:id] + @workbench = current_organisation.workbenches.find params[:id] end def sort_result collection @@ -59,7 +66,6 @@ class WorkbenchesController < BreadcrumbController def ransack_associated_lines scope if params[:q] && params[:q]['associated_lines_id_eq'] scope = scope.include_metadatas_lines([params[:q]['associated_lines_id_eq']]) - params[:q].delete('associated_lines_id_eq') end scope end |
