aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/calendars_controller.rb
diff options
context:
space:
mode:
authorZog2018-01-24 16:56:16 +0100
committercedricnjanga2018-02-06 11:10:18 -0800
commitf07802715562b31d15e31b5be90dbeac29cef227 (patch)
treef64dc33cb1bc35acaeca9261012d10516a7daf2a /app/controllers/calendars_controller.rb
parent5253b169da36a3de270f00038597b007035f09dd (diff)
downloadchouette-core-f07802715562b31d15e31b5be90dbeac29cef227.tar.bz2
Refs #5682 @3h; Use same UI as for timetables
Diffstat (limited to 'app/controllers/calendars_controller.rb')
-rw-r--r--app/controllers/calendars_controller.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb
index eaff3b0c6..3b7b6de15 100644
--- a/app/controllers/calendars_controller.rb
+++ b/app/controllers/calendars_controller.rb
@@ -1,8 +1,11 @@
class CalendarsController < ChouetteController
include PolicyChecker
+ include TimeTablesHelper
+
defaults resource_class: Calendar
before_action :ransack_contains_date, only: [:index]
respond_to :html
+ respond_to :json, only: :show
respond_to :js, only: :index
belongs_to :workgroup
@@ -21,6 +24,32 @@ class CalendarsController < ChouetteController
end
end
+ def month
+ @date = params['date'] ? Date.parse(params['date']) : Date.today
+ @calendar = resource
+ end
+
+ def create
+ create! do
+ if @calendar.valid? && has_feature?('application_days_on_calendars')
+ redirect_to([:edit, @calendar])
+ return
+ end
+ end
+ end
+
+ def update
+ if params[:calendar]
+ super
+ else
+ state = JSON.parse request.raw_post
+ resource.state_update state
+ respond_to do |format|
+ format.json { render json: state, status: state['errors'] ? :unprocessable_entity : :ok }
+ end
+ end
+ end
+
private
def decorate_calendars(calendars)