diff options
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/calendars_controller.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index de8f9d10c..43ed0cfd9 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 def index @@ -14,6 +17,32 @@ class CalendarsController < ChouetteController def show 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 calendar_params permitted_params = [:id, :name, :short_name, :shared, periods_attributes: [:id, :begin, :end, :_destroy], date_values_attributes: [:id, :value, :_destroy]] |
