mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
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
|
||||
|
||||
def delete
|
||||
registration = @conference.registrations.where(:id => params[:id]).first
|
||||
person = Person.where("id = ?", registration.person_id).first
|
||||
if has_role?(current_user, "Admin")
|
||||
registration = @conference.registrations.where(:id => params[:id]).first
|
||||
person = Person.where("id = ?", registration.person_id).first
|
||||
|
||||
begin registration.destroy
|
||||
redirect_to admin_conference_registrations_path
|
||||
flash[:notice] = "Deleted registration for #{person.public_name} #{person.email}"
|
||||
rescue Exception => e
|
||||
Rails.logger.debug e.backtrace.join("\n")
|
||||
redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'Failed to delete registration:' + e.message)
|
||||
return
|
||||
begin registration.destroy
|
||||
redirect_to admin_conference_registrations_path
|
||||
flash[:notice] = "Deleted registration for #{person.public_name} #{person.email}"
|
||||
rescue Exception => e
|
||||
Rails.logger.debug e.backtrace.join("\n")
|
||||
redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'Failed to delete registration:' + e.message)
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue