Class: EventsController
Instance Method Summary
collapse
#advertise, #cache_action?, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index
Methods included from BaseHelper
#add_friend_link, #ajax_spinner_for, #avatar_for, #block_to_partial, #box, #city_cloud, #clippings_link, #commentable_url, #container_title, #excerpt_with_jump, #flash_class, #forum_page?, #is_current_user_and_featured?, #jumbotron, #last_active, #more_comments_links, #page_title, #paginating_links, #possesive, #profile_completeness, #render_jumbotron, #render_widgets, #rounded, #search_posts_title, #search_user_posts_path, #show_footer_content?, #tag_auto_complete_field, #time_ago_in_words, #time_ago_in_words_or_date, #topnav_tab, #truncate_words, #truncate_words_with_highlight, #widget
#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale
#login_by_token, #update_last_seen_at
Instance Method Details
#clone ⇒ Object
118
119
120
121
122
123
|
# File 'app/controllers/events_controller.rb', line 118
def clone
@event = Event.find(params[:id]).clone
@metro_areas, @states = setup_metro_area_choices_for(@event)
@metro_area_id, @state_id, @country_id = setup_location_for(@event)
render :template => 'events/new'
end
|
#create ⇒ Object
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
|
# File 'app/controllers/events_controller.rb', line 57
def create
@event = Event.new(event_params)
@event.user = current_user
if params[:metro_area_id]
@event.metro_area = MetroArea.find(params[:metro_area_id])
else
@event.metro_area = nil
end
respond_to do |format|
if @event.save
flash[:notice] = :event_was_successfully_created.l
format.html { redirect_to event_path(@event) }
else
format.html {
@metro_areas, @states = setup_metro_area_choices_for(@event)
if params[:metro_area_id]
@metro_area_id = params[:metro_area_id].to_i
@state_id = params[:state_id].to_i
@country_id = params[:country_id].to_i
end
render :action => "new"
}
end
end
end
|
#destroy ⇒ Object
109
110
111
112
113
114
115
116
|
# File 'app/controllers/events_controller.rb', line 109
def destroy
@event = Event.find(params[:id])
@event.destroy
respond_to do |format|
format.html { redirect_to :back }
end
end
|
#edit ⇒ Object
51
52
53
54
55
|
# File 'app/controllers/events_controller.rb', line 51
def edit
@event = Event.find(params[:id])
@metro_areas, @states = setup_metro_area_choices_for(@event)
@metro_area_id, @state_id, @country_id = setup_location_for(@event)
end
|
#ical ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/events_controller.rb', line 9
def ical
@calendar = RiCal.Calendar
@calendar.add_x_property 'X-WR-CALNAME', configatron.
@calendar.add_x_property 'X-WR-CALDESC', "#{configatron.} #{:events.l}"
Event.all.each do |ce_event|
rical_event = RiCal.Event do |event|
event.dtstart = ce_event.start_time
event.dtend = ce_event.end_time
event.summary = ce_event.name + (ce_event.metro_area.blank? ? '' : " (#{ce_event.metro_area})")
coder = HTMLEntities.new
event.description = (ce_event.description.blank? ? '' : coder.decode(view_context.strip_tags(ce_event.description).to_s) + "\n\n") + event_url(ce_event)
event.location = ce_event.location unless ce_event.location.blank?
end
@calendar.add_subcomponent rical_event
end
['Content-Type'] = "text/calendar; charset=UTF-8"
render :text => @calendar.export_to, :layout => false
end
|
#index ⇒ Object
34
35
36
37
|
# File 'app/controllers/events_controller.rb', line 34
def index
@is_admin_user = (current_user && current_user.admin?)
@events = Event.upcoming.page(params[:page])
end
|
#new ⇒ Object
45
46
47
48
49
|
# File 'app/controllers/events_controller.rb', line 45
def new
@event = Event.new
@metro_areas, @states = setup_metro_area_choices_for(current_user)
@metro_area_id, @state_id, @country_id = setup_location_for(current_user)
end
|
#past ⇒ Object
39
40
41
42
43
|
# File 'app/controllers/events_controller.rb', line 39
def past
@is_admin_user = (current_user && current_user.admin?)
@events = Event.past.page(params[:page])
render :template => 'events/index'
end
|
#show ⇒ Object
28
29
30
31
32
|
# File 'app/controllers/events_controller.rb', line 28
def show
@is_admin_user = (current_user && current_user.admin?)
@event = Event.find(params[:id])
@comments = @event..includes(:user).order('created_at DESC').limit(20)
end
|
#update ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'app/controllers/events_controller.rb', line 84
def update
@event = Event.find(params[:id])
if params[:metro_area_id]
@event.metro_area = MetroArea.find(params[:metro_area_id])
else
@event.metro_area = nil
end
respond_to do |format|
if @event.update_attributes(event_params)
format.html { redirect_to event_path(@event) }
else
format.html {
@metro_areas, @states = setup_metro_area_choices_for(@event)
if params[:metro_area_id]
@metro_area_id = params[:metro_area_id].to_i
@state_id = params[:state_id].to_i
@country_id = params[:country_id].to_i
end
render :action => "edit"
}
end
end
end
|