clarion/app/controllers/management/events_controller.rb

84 lines
2.0 KiB
Ruby
Raw Normal View History

module Management
class EventsController < ManagementController
def index
@conference = find_conference
@filters = filter_params || {}
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)
2019-04-28 21:10:54 +03:00
flash[:notice] = t(".event_successfully_updated")
redirect_to [:management, @conference, @event]
2015-07-14 21:00:02 +03:00
else
2019-04-28 21:10:54 +03:00
render action: "edit"
2015-07-14 21:00:02 +03:00
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
def filter_params
params.fetch(:filters, {}).permit(
:event_type_id,
:track_id,
:language,
:status,
:confirmed,
:not_confirmed,
)
end
2015-07-14 21:00:02 +03:00
def event_params
params.require(:event).permit(
2019-04-28 21:10:54 +03:00
:title,
:subtitle,
:length,
:language,
:abstract,
:description,
:notes,
:track_id,
:event_type_id,
participations_attributes: [
:id,
:participant_id,
:approved,
:_destroy,
]
)
end
end
end