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] || {}
|
2016-10-15 05:59:07 +03:00
|
|
|
@events = EventSearch.new(scope: Event.where(conference: @conference).eager_load(:participants_with_personal_profiles, :proposition, :proposer, :track, :event_type).preload(:conference), filters: params[:filters]).results
|
2016-10-08 19:29:08 +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
|
|
|
|
2016-10-09 02:13:36 +03:00
|
|
|
if @event.update(event_params)
|
2019-01-08 18:16:50 +02:00
|
|
|
flash[:notice] = t('.event_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
|