clarion/app/controllers/management/events_controller.rb

73 lines
2.3 KiB
Ruby
Raw Normal View History

module Management
class EventsController < ManagementController
def index
@conference = find_conference
@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
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