2014-09-30 13:34:09 +03:00
|
|
|
module Management
|
|
|
|
class EventsController < ManagementController
|
|
|
|
def index
|
2015-07-19 11:44:44 +03:00
|
|
|
@conference = find_conference
|
2015-10-15 19:12:56 +03:00
|
|
|
@events = @conference.events.order(:title).includes(:proposition, :proposer, :track, :event_type)
|
2014-10-10 20:25:41 +03:00
|
|
|
end
|
|
|
|
|
2014-09-30 13:34:09 +03:00
|
|
|
def show
|
2015-07-19 11:44:44 +03:00
|
|
|
@conference = find_conference
|
2015-07-19 14:11:44 +03:00
|
|
|
@event = @conference.events.find(params[:id])
|
2015-07-14 21:00:02 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2015-07-19 11:44:44 +03:00
|
|
|
@conference = find_conference
|
2015-07-19 14:11:44 +03:00
|
|
|
@event = @conference.events.find(params[:id])
|
2015-07-14 21:00:02 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-07-19 11:44:44 +03:00
|
|
|
@conference = find_conference
|
2015-07-19 14:11:44 +03:00
|
|
|
@event = @conference.events.find(params[:id])
|
2015-07-14 21:00:02 +03:00
|
|
|
|
|
|
|
if @event.update_attributes(event_params)
|
|
|
|
flash[:notice] = 'Event was successfully updated.'
|
|
|
|
redirect_to [:management, @event]
|
|
|
|
else
|
|
|
|
render action: 'edit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2015-07-19 11:44:44 +03:00
|
|
|
@conference = find_conference
|
2015-07-19 14:11:44 +03:00
|
|
|
@event = @conference.events.find(params[:id])
|
2015-07-14 21:00:02 +03:00
|
|
|
@event.destroy
|
|
|
|
|
|
|
|
redirect_to action: :index
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-07-19 11:44:44 +03:00
|
|
|
def find_conference
|
|
|
|
Conference.find(params[:conference_id])
|
|
|
|
end
|
|
|
|
|
2015-07-14 21:00:02 +03:00
|
|
|
def event_params
|
|
|
|
params.require(:event).permit(
|
|
|
|
:title,
|
|
|
|
:subtitle,
|
|
|
|
:length,
|
|
|
|
:language,
|
|
|
|
:abstract,
|
|
|
|
:description,
|
|
|
|
:notes
|
|
|
|
)
|
2014-09-30 13:34:09 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|