osem-fcy/app/controllers/admin/volunteers_controller.rb

40 lines
1.2 KiB
Ruby
Raw Normal View History

2014-08-06 21:14:00 +03:00
module Admin
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
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
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
end
2014-08-06 21:14:00 +03:00
def update
if can_manage_volunteers(@conference)
if @conference.update_attributes(params[:conference])
2015-10-17 16:57:48 +03:00
flash[:notice] = 'Volunteering options were successfully updated.'
redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id])
else
2015-10-17 16:57:48 +03:00
flash[:error] = "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}"
redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id])
2014-08-12 11:51:59 +03:00
end
else
authorize! :index, :volunteer
2014-08-06 21:14:00 +03:00
end
end
end
end