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
|
2016-10-08 19:29:08 +03:00
|
|
|
@filters = params[:filters] || {}
|
|
|
|
@events = EventSearch.new(scope: Event.where(conference: @conference).eager_load(:proposition, :proposer, :track, :event_type), filters: params[:filters]).results
|
|
|
|
# @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
|
|
|
|
2016-10-09 02:13:36 +03:00
|
|
|
if @event.update(event_params)
|
2015-07-14 21:00:02 +03:00
|
|
|
flash[:notice] = 'Event was successfully updated.'
|
2016-10-09 02:13:36 +03:00
|
|
|
redirect_to [:management, @conference, @event]
|
2015-07-14 21:00:02 +03:00
|
|
|
else
|
|
|
|
render action: 'edit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-13 10:39:45 +03:00
|
|
|
def conflicts
|
|
|
|
@conference = find_conference
|
|
|
|
@event = @conference.events.find(params[:id])
|
|
|
|
@conflicts = @event.conflict_counts
|
|
|
|
end
|
|
|
|
|
2015-07-14 21:00:02 +03:00
|
|
|
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(
|
2016-10-09 02:13:36 +03:00
|
|
|
:title,
|
|
|
|
:subtitle,
|
|
|
|
:length,
|
|
|
|
:language,
|
|
|
|
:abstract,
|
|
|
|
:description,
|
|
|
|
:notes,
|
|
|
|
:track_id,
|
|
|
|
:event_type_id,
|
|
|
|
participations_attributes: [
|
|
|
|
:id,
|
|
|
|
:participant_id,
|
|
|
|
:approved,
|
|
|
|
:_destroy
|
|
|
|
]
|
|
|
|
)
|
2014-09-30 13:34:09 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|