diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index a0768411..f5d48f4b 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -28,4 +28,18 @@ class Admin::RegistrationsController < ApplicationController redirect_to admin_conference_registrations_path(@conference.short_title, @registration) flash[:notice] = "Updated '#{params[:view_field]}' for #{(Person.where("id = ?", @registration.person_id).first).email}" end + + def delete + 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 + end + end end \ No newline at end of file diff --git a/app/views/admin/registrations/show.html.haml b/app/views/admin/registrations/show.html.haml index cb2535bc..136a286d 100644 --- a/app/views/admin/registrations/show.html.haml +++ b/app/views/admin/registrations/show.html.haml @@ -40,7 +40,7 @@ %td = link_to "Edit", "#", :class => "btn btn-primary" %td - = link_to "Delete", "#", :class => "btn btn-danger", :confirm => "Really delete registration for #{registration.public_name}?" + = link_to "Delete", admin_conference_registrations_path(@conference.short_title, :id => registration.id), :method => :delete, :class => "btn btn-danger", :confirm => "Really delete registration for #{registration.public_name} #{registration.email}?" :javascript $(document).ready(function() { diff --git a/config/routes.rb b/config/routes.rb index 3713964d..38074bfa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,7 @@ Osem::Application.routes.draw do put "/schedule" => "schedule#update" get "/registrations" => "registrations#show" put "/registrations/change_field" => "registrations#change_field" + delete "/registrations" => "registrations#delete" get "/emailsettings" => "emails#show", :as => "email_settings" put "/emailsettings" => "emails#update", :as => "email_settings" get "/supporter_levels" => "SupporterLevels#show"