aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/calendars_controller.rb
diff options
context:
space:
mode:
authorcedricnjanga2018-01-24 19:55:56 -0800
committercedricnjanga2018-02-07 07:20:18 -0800
commit4792234e05ca99012af9dae0858664a131c45c4f (patch)
tree5654c47858864654e23c5d378083faa6ccdd815b /app/controllers/calendars_controller.rb
parent308bf4338b3e79016e353555ee3677c917c71805 (diff)
downloadchouette-core-4792234e05ca99012af9dae0858664a131c45c4f.tar.bz2
update calendar build_links for table builder
Diffstat (limited to 'app/controllers/calendars_controller.rb')
-rw-r--r--app/controllers/calendars_controller.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb
index 585851f00..17297c758 100644
--- a/app/controllers/calendars_controller.rb
+++ b/app/controllers/calendars_controller.rb
@@ -1,4 +1,5 @@
class CalendarsController < ChouetteController
+ include WorkgroupSupport
include PolicyChecker
include TimeTablesHelper
@@ -54,10 +55,18 @@ 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
@@ -82,17 +91,30 @@ 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)
@@ -101,6 +123,16 @@ 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