Class: Caboose::CalendarsController
Instance Method Summary
collapse
#add_ga_event, #admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_json, #admin_json_single, #before_before_action, #hashify_query_string, #init_cart, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #under_construction_or_forwarding_domain?, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in
Instance Method Details
#admin_add ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'app/controllers/caboose/calendars_controller.rb', line 52
def admin_add
return unless user_is_allowed('calendars', 'edit')
resp = StdClass.new
calendar = Calendar.new
calendar.name = params[:name]
calendar.site_id = @site.id
if calendar.name.nil? || calendar.name.strip.length == 0
resp.error = "Please enter a calendar name."
else
calendar.save
resp.redirect = "/admin/calendars/#{calendar.id}"
end
render :json => resp
end
|
#admin_delete ⇒ Object
70
71
72
73
74
75
|
# File 'app/controllers/caboose/calendars_controller.rb', line 70
def admin_delete
return unless user_is_allowed('calendars', 'delete')
Calendar.find(params[:id]).destroy
resp = StdClass.new({ 'redirect' => "/admin/calendars" })
render :json => resp
end
|
#admin_edit ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/caboose/calendars_controller.rb', line 21
def admin_edit
return unless user_is_allowed('calendars', 'edit')
@calendar = Calendar.find(params[:id])
@d = params[:d] ? DateTime.iso8601(params[:d]) : DateTime.now
@d = @d - (@d.strftime('%-d').to_i-1)
render :layout => 'caboose/admin'
end
|
#admin_index ⇒ Object
12
13
14
15
16
17
18
|
# File 'app/controllers/caboose/calendars_controller.rb', line 12
def admin_index
return if !user_is_allowed('calendars', 'view')
render :file => 'caboose/extras/error_invalid_site' and return if @site.nil?
@calendars = Calendar.where(:site_id => @site.id).reorder(:name).all
render :layout => 'caboose/admin'
end
|
#admin_update ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/caboose/calendars_controller.rb', line 32
def admin_update
return unless user_is_allowed('calendars', 'edit')
resp = StdClass.new({'attributes' => {}})
calendar = Calendar.find(params[:id])
save = true
params.each do |name, value|
case name
when 'name' then calendar.name = value
when 'description' then calendar.description = value
when 'color' then calendar.color = value
end
end
resp.success = save && calendar.save
render :json => resp
end
|
#before_action ⇒ Object
7
8
9
|
# File 'app/controllers/caboose/calendars_controller.rb', line 7
def before_action
@page = Page.page_with_uri(request.host_with_port, '/admin')
end
|