diff options
| author | cedricnjanga | 2018-01-30 23:07:07 -0800 |
|---|---|---|
| committer | cedricnjanga | 2018-02-06 11:17:20 -0800 |
| commit | eaa3c0156f8774ef396854ef4819e27815720d6d (patch) | |
| tree | 1e3990a5fc5edaf08916f0ddf2b61e43f6f7336f /app | |
| parent | 388fe8128caf7c36a7c4c89380a98bb5530955d1 (diff) | |
| download | chouette-core-eaa3c0156f8774ef396854ef4819e27815720d6d.tar.bz2 | |
Make some changes to avoid unnacessaty lines of code
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/calendars_controller.rb | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index cc160a98e..3018b48e1 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -1,5 +1,4 @@ class CalendarsController < ChouetteController - include WorkgroupSupport include PolicyChecker include TimeTablesHelper @@ -8,6 +7,8 @@ class CalendarsController < ChouetteController respond_to :html respond_to :json, only: :show respond_to :js, only: :index + + belongs_to :workgroup belongs_to :workgroup @@ -55,18 +56,10 @@ class CalendarsController < ChouetteController private def decorate_calendars(calendars) -<<<<<<< HEAD CalendarDecorator.decorate( calendars, context: { workgroup: workgroup -======= - ModelDecorator.decorate( - calendars, - with: CalendarDecorator, - context: { - workgroup: current_workgroup ->>>>>>> update calendar build_links for table builder } ) end @@ -91,30 +84,17 @@ class CalendarsController < ChouetteController helper_method :workgroup def resource -<<<<<<< HEAD @calendar ||= workgroup.calendars.where('(organisation_id = ? OR shared = ?)', current_organisation.id, true).find_by_id(params[:id]) -======= -<<<<<<< HEAD - @calendar = Calendar.where('organisation_id = ? OR shared = true', current_organisation.id).find_by_id(params[:id]).decorate -======= - @calendar = Calendar.where('(organisation_id = ? OR shared = ?) AND workgroup_id = ?', current_organisation.id).find_by_id(params[:id], true, @workgroup.id) ->>>>>>> update calendar build_links for table builder ->>>>>>> update calendar build_links for table builder end def build_resource super.tap do |calendar| -<<<<<<< HEAD calendar.workgroup = workgroup -======= - calendar.workgroup = current_workgroup ->>>>>>> update calendar build_links for table builder calendar.organisation = current_organisation end end def collection -<<<<<<< HEAD @calendars ||= begin scope = workgroup.calendars.where('(organisation_id = ? OR shared = ?)', current_organisation.id, true) scope = shared_scope(scope) @@ -123,16 +103,6 @@ class CalendarsController < ChouetteController calendars = calendars.order(sort_column + ' ' + sort_direction) if sort_column && sort_direction calendars = calendars.paginate(page: params[:page]) end -======= - return @calendars if @calendars - scope = Calendar.where('(organisation_id = ? OR shared = ?) AND workgroup_id = ?', current_organisation.id, true, @workgroup.id) - 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]) ->>>>>>> update calendar build_links for table builder end def ransack_contains_date |
