Allow delete of registration only to admins (not organizers)

This commit is contained in:
differentreality 2013-07-12 11:06:16 +03:00
parent 6879ca28e5
commit 463430b3e8

View file

@ -30,6 +30,7 @@ class Admin::RegistrationsController < ApplicationController
end end
def delete def delete
if has_role?(current_user, "Admin")
registration = @conference.registrations.where(:id => params[:id]).first registration = @conference.registrations.where(:id => params[:id]).first
person = Person.where("id = ?", registration.person_id).first person = Person.where("id = ?", registration.person_id).first
@ -41,5 +42,8 @@ class Admin::RegistrationsController < ApplicationController
redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'Failed to delete registration:' + e.message) redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'Failed to delete registration:' + e.message)
return return
end end
else
redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'You must be an admin to delete a registration.')
end
end end
end end