2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2014-08-06 21:14:00 +03:00
|
|
|
module Admin
|
2014-08-13 14:37:05 +03:00
|
|
|
class VolunteersController < Admin::BaseController
|
2017-03-16 22:31:42 +05:30
|
|
|
include VolunteersHelper
|
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
|
2017-03-17 18:50:29 +05:30
|
|
|
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
|
2017-03-17 18:50:29 +05:30
|
|
|
if can_manage_volunteers?(@conference)
|
2017-07-14 14:12:54 +02:00
|
|
|
@volunteers = if @conference.use_vpositions
|
|
|
|
|
@conference.registrations.joins(:vchoices).uniq
|
|
|
|
|
else
|
|
|
|
|
@conference.registrations.where(volunteer: true)
|
|
|
|
|
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
|
2022-02-14 17:53:58 +01:00
|
|
|
if @conference.update(conference_params)
|
2016-03-11 02:08:00 +05:30
|
|
|
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-03-16 11:20:56 +05:30
|
|
|
redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), error: "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
|