From fe7915ffac359db41c7737a3847f31a728f502e6 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 31 Jan 2018 11:39:39 +0100 Subject: Refs #5683 @2H; Fix specs and refactor action_links Note: Did not fix the missing workgroup in the calendar mailer --- app/controllers/calendars_controller.rb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'app/controllers/calendars_controller.rb') diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 193680342..6f1522428 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -4,7 +4,7 @@ class CalendarsController < ChouetteController before_action :ransack_contains_date, only: [:index] respond_to :html respond_to :js, only: :index - + belongs_to :workgroup def index @@ -24,9 +24,8 @@ class CalendarsController < ChouetteController private def decorate_calendars(calendars) - ModelDecorator.decorate( + CalendarDecorator.decorate( calendars, - with: CalendarDecorator, context: { workgroup: workgroup } @@ -65,13 +64,13 @@ class CalendarsController < ChouetteController def collection @calendars ||= begin - scope = workgroup.calendars.where('(organisation_id = ? OR shared = ?)', current_organisation.id, true) - scope = shared_scope(scope) - @q = scope.ransack(params[:q]) - calendars = @q.result - calendars = calendars.order(sort_column + ' ' + sort_direction) if sort_column && sort_direction - calendars = calendars.paginate(page: params[:page]) - end + scope = workgroup.calendars.where('(organisation_id = ? OR shared = ?)', current_organisation.id, true) + scope = shared_scope(scope) + @q = scope.ransack(params[:q]) + calendars = @q.result + calendars = calendars.order(sort_column + ' ' + sort_direction) if sort_column && sort_direction + calendars = calendars.paginate(page: params[:page]) + end end def ransack_contains_date @@ -96,4 +95,4 @@ class CalendarsController < ChouetteController scope end -end \ No newline at end of file +end -- cgit v1.2.3