2014-08-06 21:14:00 +03:00
|
|
|
module Admin
|
2014-08-13 14:37:05 +03:00
|
|
|
class VolunteersController < Admin::BaseController
|
2014-08-12 11:51:59 +03:00
|
|
|
load_and_authorize_resource :conference, find_by: :short_title
|
|
|
|
|
|
2014-08-06 21:14:00 +03:00
|
|
|
def index
|
2014-08-13 22:46:41 +03:00
|
|
|
if can_manage_volunteers(@conference)
|
2014-08-12 11:51:59 +03:00
|
|
|
render :index
|
|
|
|
|
else
|
|
|
|
|
authorize! :index, :volunteer
|
|
|
|
|
end
|
2014-08-06 21:14:00 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show
|
2014-08-13 22:46:41 +03:00
|
|
|
if can_manage_volunteers(@conference)
|
2014-08-12 11:51:59 +03:00
|
|
|
if @conference.use_vpositions
|
|
|
|
|
@volunteers = @conference.registrations.joins(:vchoices).uniq
|
|
|
|
|
else
|
2014-08-12 15:48:29 +03:00
|
|
|
@volunteers = @conference.registrations.where(volunteer: true)
|
2014-08-12 11:51:59 +03:00
|
|
|
end
|
2014-08-06 21:14:00 +03:00
|
|
|
else
|
2014-08-12 11:51:59 +03:00
|
|
|
authorize! :index, :volunteer
|
2014-08-06 21:14:00 +03:00
|
|
|
end
|
2014-03-04 22:22:52 +02:00
|
|
|
end
|
2014-01-01 11:39:59 +02:00
|
|
|
|
2014-08-06 21:14:00 +03:00
|
|
|
def update
|
2016-01-13 12:33:37 +02:00
|
|
|
if @conference.update_attributes(conference_params)
|
|
|
|
|
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.')
|
2014-08-12 11:51:59 +03:00
|
|
|
else
|
2016-01-13 12:33:37 +02:00
|
|
|
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}")
|
2014-08-06 21:14:00 +03:00
|
|
|
end
|
2014-01-01 11:39:59 +02:00
|
|
|
end
|
2015-10-28 18:05:15 +02:00
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def conference_params
|
2016-01-13 12:33:37 +02:00
|
|
|
params.require(:conference).permit(:use_volunteers, :use_vdays, :use_vpositions)
|
2015-10-28 18:05:15 +02:00
|
|
|
end
|
2014-01-01 11:39:59 +02:00
|
|
|
end
|
|
|
|
|
end
|