Class: Admin::CalendarItemsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/admin/calendar_items_controller.rb

Overview

This RESTful controller is used to orchestrate and control the flow of the application relating to Meeting objects.

Instance Method Summary (collapse)

Instance Method Details

- (Object) create

  • POST /admin/calendar_items

  • POST /admin/calendar_items.xml



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/controllers/admin/calendar_items_controller.rb', line 55

def create
  @calendar_item        = CalendarItem.new(params[:calendar_item])
  @calendar_item.parent = @parent_node

  respond_to do |format|
    if @commit_type == 'preview' && @calendar_item.valid?
      format.html { render :action => 'create_preview', :layout => 'admin/admin_preview' }
      format.xml  { render :xml => @calendar_item, :status => :created, :location => @calendar_item }
    elsif @commit_type == 'save' && @calendar_item.save_for_user(current_user)
      format.html do
        if params[:continue].present?
          @repeat_interval_multipliers   = CalendarItem.repeat_interval_multipliers
          @repeat_interval_granularities = CalendarItem.repeat_interval_granularities
          @calendar_item                 = CalendarItem.new

          render :action => :new
        else
          render :template => 'admin/shared/create'
        end
      end
      format.xml  { render :xml => @calendar_item, :status => :created, :location => @calendar_item }
    else
      format.html do 
        @repeat_interval_multipliers   = CalendarItem.repeat_interval_multipliers
        @repeat_interval_granularities = CalendarItem.repeat_interval_granularities
        render :action => :new
      end
      format.xml  { render :xml => @calendar_item.errors, :status => :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /admin/calendar_items/:id



113
114
115
116
117
118
119
120
# File 'app/controllers/admin/calendar_items_controller.rb', line 113

def destroy
  CalendarItem.destroy_calendar_item(@calendar_item)

  respond_to do |format|
    format.xml  { head :ok }
    format.json { render :json => { :notice => I18n.t('calendars.succesfully_destroyed') }.to_json, :status => :ok }
  end  
end

- (Object) edit

  • GET /admin/calendar_items/:id/edit



49
50
51
# File 'app/controllers/admin/calendar_items_controller.rb', line 49

def edit
  @calendar_item.attributes = params[:calendar_item]
end

- (Object) new

  • GET /admin/calendar_items/new



42
43
44
45
46
# File 'app/controllers/admin/calendar_items_controller.rb', line 42

def new
  @repeat_interval_multipliers   = CalendarItem.repeat_interval_multipliers
  @repeat_interval_granularities = CalendarItem.repeat_interval_granularities
  @calendar_item                 = CalendarItem.new(params[:calendar_item] || {})
end

- (Object) previous

  • GET /admin/calendar_items/:id/previous

  • GET /admin/calendar_items/:id/previous.xml



36
37
38
39
# File 'app/controllers/admin/calendar_items_controller.rb', line 36

def previous
  @calendar_item = @calendar_item.previous_version
  show
end

- (Object) show

  • GET /admin/calendar_items/:id

  • GET /admin/calendar_items/:id.xml



27
28
29
30
31
32
# File 'app/controllers/admin/calendar_items_controller.rb', line 27

def show
  respond_to do |format|
    format.html { render :partial => '/admin/calendar_items/show', :locals => { :record => @calendar_item }, :layout => 'admin/admin_show' }
    format.xml  { render :xml => @calendar_item }
  end
end

- (Object) update

  • PUT /admin/calendar_items/:id

  • PUT /admin/calendar_items/publication_date1.xml



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'app/controllers/admin/calendar_items_controller.rb', line 89

def update
  @calendar_item.attributes = params[:calendar_item]

  respond_to do |format|
    if @commit_type == 'preview' && @calendar_item.valid?
      format.html do
        find_children
        render :action => 'update_preview', :layout => 'admin/admin_preview'
      end
      format.xml  { render :xml => @calendar_item, :status => :created, :location => @calendar_item }
    elsif @commit_type == 'save' && @calendar_item.save_for_user(current_user, @for_approval)
      format.html {
        @refresh = true
        render :template => 'admin/shared/update'
      }
      format.xml  { head :ok }
    else
      format.html { render :action => :edit }
      format.xml  { render :xml => @calendar_item.errors, :status => :unprocessable_entity }
    end
  end
end