Class: Calagator::EventsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Calagator::EventsController
- Includes:
- DuplicateChecking::ControllerActions
- Defined in:
- app/controllers/calagator/events_controller.rb
Instance Method Summary collapse
- #clone ⇒ Object
-
#create ⇒ Object
POST /events POST /events.xml.
- #create_or_update ⇒ Object
-
#destroy ⇒ Object
DELETE /events/1 DELETE /events/1.xml.
-
#edit ⇒ Object
GET /events/1/edit.
-
#index ⇒ Object
GET /events GET /events.xml.
-
#new ⇒ Object
GET /events/new GET /events/new.xml.
-
#search ⇒ Object
GET /events/search.
-
#show ⇒ Object
GET /events/1 GET /events/1.xml.
-
#update ⇒ Object
PUT /events/1 PUT /events/1.xml.
Methods included from DuplicateChecking::ControllerActions
#duplicates, #squash_many_duplicates
Methods inherited from ApplicationController
Instance Method Details
#clone ⇒ Object
105 106 107 108 109 |
# File 'app/controllers/calagator/events_controller.rb', line 105 def clone @event = Event::Cloner.clone(Event.find(params[:id])) flash[:success] = 'This is a new event cloned from an existing one. Please update the fields, like the time and description.' render 'new' end |
#create ⇒ Object
POST /events POST /events.xml
46 47 48 49 |
# File 'app/controllers/calagator/events_controller.rb', line 46 def create @event = Event.new create_or_update end |
#create_or_update ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/calagator/events_controller.rb', line 57 def create_or_update saver = Event::Saver.new(@event, params.permit!) respond_to do |format| if recaptcha_verified?(@event) && saver.save format.html do flash[:success] = 'Event was successfully saved.' if saver.has_new_venue? flash[:success] += " Please tell us more about where it's being held." redirect_to edit_venue_url(@event.venue, from_event: @event.id) else redirect_to @event end end format.xml { render xml: @event, status: :created, location: @event } else format.html do flash[:failure] = saver.failure render action: @event.new_record? ? 'new' : 'edit' end format.xml { render xml: @event.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /events/1 DELETE /events/1.xml
83 84 85 86 87 88 89 90 |
# File 'app/controllers/calagator/events_controller.rb', line 83 def destroy @event.destroy respond_to do |format| format.html { redirect_to(events_url, flash: { success: "\"#{@event.title}\" has been deleted" }) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /events/1/edit
42 |
# File 'app/controllers/calagator/events_controller.rb', line 42 def edit; end |
#index ⇒ Object
GET /events GET /events.xml
17 18 19 20 21 22 |
# File 'app/controllers/calagator/events_controller.rb', line 17 def index @browse = Event::Browse.new(params) @events = @browse.events @browse.errors.each { |error| append_flash :failure, error } render_events @events end |
#new ⇒ Object
GET /events/new GET /events/new.xml
37 38 39 |
# File 'app/controllers/calagator/events_controller.rb', line 37 def new @event = Event.new(params.permit![:event]) end |
#search ⇒ Object
GET /events/search
93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/controllers/calagator/events_controller.rb', line 93 def search @search = Event::Search.new(params) # setting @events so that we can reuse the index atom builder @events = @search.events flash[:failure] = @search. return redirect_to root_path if @search.hard_failure? render_events(@events) end |
#show ⇒ Object
GET /events/1 GET /events/1.xml
26 27 28 29 30 31 32 33 |
# File 'app/controllers/calagator/events_controller.rb', line 26 def show @event = Event.find(params[:id]) return redirect_to(@event.originator) if @event.duplicate? render_event @event rescue ActiveRecord::RecordNotFound => e redirect_to events_path, flash: { failure: e.to_s } end |
#update ⇒ Object
PUT /events/1 PUT /events/1.xml
53 54 55 |
# File 'app/controllers/calagator/events_controller.rb', line 53 def update create_or_update end |