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

39 lines
1.4 KiB
Ruby
Raw Normal View History

2014-08-06 21:14:00 +03:00
module Admin
class VolunteersController < ApplicationController
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-12 11:51:59 +03:00
if (current_user.has_role? :organizer, @conference) || (current_user.has_role? :volunteer_coordinator, @conference)
render :index
else
authorize! :index, :volunteer
end
2014-08-06 21:14:00 +03:00
end
def show
2014-08-12 11:51:59 +03:00
if (current_user.has_role? :organizer, @conference) || (current_user.has_role? :volunteer_coordinator, @conference)
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
2014-08-12 11:51:59 +03:00
if (current_user.has_role? :organizer, @conference) || (current_user.has_role? :volunteer_coordinator, @conference)
begin
@conference.update_attributes!(params[:conference])
2014-08-12 15:48:29 +03:00
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
rescue Exception => e
2014-08-12 15:48:29 +03:00
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{e.message}")
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