Allow delete of registration only to admins (not organizers)
This commit is contained in:
parent
6879ca28e5
commit
463430b3e8
1 changed files with 13 additions and 9 deletions
|
|
@ -30,16 +30,20 @@ class Admin::RegistrationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
registration = @conference.registrations.where(:id => params[:id]).first
|
if has_role?(current_user, "Admin")
|
||||||
person = Person.where("id = ?", registration.person_id).first
|
registration = @conference.registrations.where(:id => params[:id]).first
|
||||||
|
person = Person.where("id = ?", registration.person_id).first
|
||||||
|
|
||||||
begin registration.destroy
|
begin registration.destroy
|
||||||
redirect_to admin_conference_registrations_path
|
redirect_to admin_conference_registrations_path
|
||||||
flash[:notice] = "Deleted registration for #{person.public_name} #{person.email}"
|
flash[:notice] = "Deleted registration for #{person.public_name} #{person.email}"
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
Rails.logger.debug e.backtrace.join("\n")
|
Rails.logger.debug e.backtrace.join("\n")
|
||||||
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
|
||||||
|
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
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue