2014-10-14 18:27:28 +03:00
|
|
|
module Management
|
|
|
|
class ConferencesController < ManagementController
|
|
|
|
def new
|
|
|
|
@conference = Conference.new
|
2015-07-19 20:15:12 +03:00
|
|
|
@conference.event_types.build(name: 'Event type 1')
|
2014-10-14 23:55:17 +03:00
|
|
|
@conference.tracks.build(name: 'Track 1')
|
2014-10-14 23:07:50 +03:00
|
|
|
@conference.halls.build(name: 'Hall 1')
|
2015-09-01 11:09:26 +03:00
|
|
|
@conference.volunteer_teams.build(name: 'Volunteer Team 1')
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2015-05-30 17:18:28 +03:00
|
|
|
@conference = Conference.new(conference_params)
|
2015-04-29 13:00:17 +03:00
|
|
|
|
|
|
|
if @conference.save
|
2015-07-19 11:44:44 +03:00
|
|
|
redirect_to [:management, @conference]
|
2015-04-29 13:00:17 +03:00
|
|
|
else
|
|
|
|
render :new
|
|
|
|
end
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
|
2014-10-14 23:07:50 +03:00
|
|
|
def update
|
2015-05-30 17:24:49 +03:00
|
|
|
@conference = find_conference
|
2015-05-30 17:18:28 +03:00
|
|
|
@conference.update(conference_params)
|
2014-10-14 23:07:50 +03:00
|
|
|
@conference.save
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
|
2014-10-14 18:27:28 +03:00
|
|
|
def edit
|
2015-05-30 17:24:49 +03:00
|
|
|
@conference = find_conference
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
|
2014-10-14 20:34:33 +03:00
|
|
|
def index
|
2015-05-30 17:24:49 +03:00
|
|
|
@conferences = Conference.all.order(start_date: :desc)
|
2014-10-14 21:58:13 +03:00
|
|
|
end
|
|
|
|
|
2014-10-14 23:55:17 +03:00
|
|
|
def show
|
2015-05-30 17:24:49 +03:00
|
|
|
@conference = find_conference
|
2014-10-14 23:55:17 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2015-05-30 17:24:49 +03:00
|
|
|
@conference = find_conference
|
2014-10-14 23:55:17 +03:00
|
|
|
@conference.destroy
|
|
|
|
|
2015-07-12 11:05:38 +03:00
|
|
|
redirect_to management_root_path(current_conference: nil)
|
2014-10-14 20:34:33 +03:00
|
|
|
end
|
|
|
|
|
2016-10-11 01:52:19 +03:00
|
|
|
def update_vote_data
|
|
|
|
@conference = find_conference
|
|
|
|
|
|
|
|
begin
|
|
|
|
if @conference.update_vote_data!
|
2016-10-11 02:54:25 +03:00
|
|
|
flash[:notice] = t('.vote_data_successfully_updated')
|
2016-10-11 01:52:19 +03:00
|
|
|
else
|
2016-10-11 02:54:25 +03:00
|
|
|
flash[:alert] = t('.error_during_vote_data_save')
|
2016-10-11 01:52:19 +03:00
|
|
|
end
|
2016-10-11 02:54:25 +03:00
|
|
|
redirect_to :back
|
2016-10-11 01:52:19 +03:00
|
|
|
rescue StandardError => e
|
2016-10-11 02:54:25 +03:00
|
|
|
flash[:alert] = t('.error_during_connection_with_voting_endpoint', error: e.message)
|
|
|
|
render :vote_results
|
2016-10-11 01:52:19 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def vote_results
|
|
|
|
@conference = find_conference
|
|
|
|
end
|
|
|
|
|
2014-10-14 18:27:28 +03:00
|
|
|
private
|
|
|
|
|
2015-05-30 17:24:49 +03:00
|
|
|
def find_conference
|
|
|
|
Conference.find(params[:id])
|
2014-10-14 21:58:13 +03:00
|
|
|
end
|
|
|
|
|
2014-10-14 18:27:28 +03:00
|
|
|
def conference_params
|
2015-05-30 17:18:28 +03:00
|
|
|
params.require(:conference).permit(
|
2016-10-11 01:52:19 +03:00
|
|
|
:title, :email, :start_date, :end_date, :description, :host_name,
|
|
|
|
:planned_cfp_end_date, :vote_data_endpoint,
|
2015-08-20 00:24:22 +03:00
|
|
|
event_types_attributes: [:id, :name, :description, :maximum_length,
|
|
|
|
:minimum_length, :_destroy],
|
2015-10-18 13:54:14 +03:00
|
|
|
tracks_attributes: [:id, :name, :color, :css_class, :description,
|
2015-10-18 14:00:03 +03:00
|
|
|
:css_style, :foreground_color, :_destroy],
|
2015-09-01 11:09:26 +03:00
|
|
|
halls_attributes: [:id, :name, :_destroy],
|
|
|
|
volunteer_teams_attributes: [:id, :name, :description, :color, :_destroy]
|
2015-05-30 17:18:28 +03:00
|
|
|
)
|
2014-10-14 18:27:28 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|