diff options
| author | Zog | 2018-01-24 16:56:16 +0100 | 
|---|---|---|
| committer | cedricnjanga | 2018-02-06 11:10:18 -0800 | 
| commit | f07802715562b31d15e31b5be90dbeac29cef227 (patch) | |
| tree | f64dc33cb1bc35acaeca9261012d10516a7daf2a /app/controllers/calendars_controller.rb | |
| parent | 5253b169da36a3de270f00038597b007035f09dd (diff) | |
| download | chouette-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.rb | 29 | 
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) | 
