clarion/app/controllers/management/events_controller.rb

73 lines
2.4 KiB
Ruby
Raw Normal View History

module Management
class EventsController < ManagementController
def index
@conference = find_conference
@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
# @events = @conference.events.order(:title).includes(:proposition, :proposer, :track, :event_type)
2014-10-10 20:25:41 +03:00
end
def show
@conference = find_conference
@event = @conference.events.find(params[:id])
2015-07-14 21:00:02 +03:00
end
def edit
@conference = find_conference
@event = @conference.events.find(params[:id])
2015-07-14 21:00:02 +03:00
end
def update
@conference = find_conference
@event = @conference.events.find(params[:id])
2015-07-14 21:00:02 +03:00
if @event.update(event_params)
2015-07-14 21:00:02 +03:00
flash[:notice] = 'Event was successfully updated.'
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
@conference = find_conference
@event = @conference.events.find(params[:id])
2015-07-14 21:00:02 +03:00
@event.destroy
redirect_to action: :index
end
private
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,
:track_id,
:event_type_id,
participations_attributes: [
:id,
:participant_id,
:approved,
:_destroy
]
)
end
end
end