diff options
| author | Zog | 2018-01-24 16:56:16 +0100 |
|---|---|---|
| committer | Zog | 2018-01-31 15:14:00 +0100 |
| commit | 663effc415399c61d22dadbc235bb7488022d191 (patch) | |
| tree | cc943f110c9245575c75ebe6cac4b7bfd7152149 /app/controllers | |
| parent | b83d26389e6726eaea86955c3a2d2bffa5e65b5e (diff) | |
| download | chouette-core-663effc415399c61d22dadbc235bb7488022d191.tar.bz2 | |
Refs #5682 @3h; Use same UI as for timetables
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]] |
