Scope event operations to the current conference

An indirect Conference -> Track -> Proposition -> Event relation exists
within the data model. Use it to limit all operations in the Events
controller to events, associated with the current conference.
This commit is contained in:
Petko Bordjukov 2015-07-19 14:11:44 +03:00
parent 1bec127503
commit 0ece79a8ae
1 changed files with 5 additions and 6 deletions

View File

@ -2,23 +2,22 @@ module Management
class EventsController < ManagementController class EventsController < ManagementController
def index def index
@conference = find_conference @conference = find_conference
# TODO (2015-07-14) Scoped by conference? Why no conference_id @events = @conference.events.approved
@events = Event.approved
end end
def show def show
@conference = find_conference @conference = find_conference
@event = Event.find(params[:id]) @event = @conference.events.find(params[:id])
end end
def edit def edit
@conference = find_conference @conference = find_conference
@event = Event.find(params[:id]) @event = @conference.events.find(params[:id])
end end
def update def update
@conference = find_conference @conference = find_conference
@event = Event.find(params[:id]) @event = @conference.events.find(params[:id])
if @event.update_attributes(event_params) if @event.update_attributes(event_params)
flash[:notice] = 'Event was successfully updated.' flash[:notice] = 'Event was successfully updated.'
@ -30,7 +29,7 @@ module Management
def destroy def destroy
@conference = find_conference @conference = find_conference
@event = Event.find(params[:id]) @event = @conference.events.find(params[:id])
@event.destroy @event.destroy
redirect_to action: :index redirect_to action: :index