diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 9dd8c06d..92b7a598 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -13,7 +13,7 @@ class Admin::RegistrationsController < ApplicationController people.email AS email, people.company as affiliation, people.irc_nickname as nickname") @attended = @conference.registrations.where("attended = ?", true) - @headers = %w[name email nickname affiliation social_events attending_with_partner need_access other_needs arrival departure attended] + @headers = %w[name email social_events attending_with_partner need_access other_needs arrival departure attended] end def change_field @@ -28,7 +28,7 @@ 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 edit @registration = @conference.registrations.where("id = ?", params[:id]).first @person = Person.where("id = ?", @registration.person_id).first @@ -131,4 +131,6 @@ class Admin::RegistrationsController < ApplicationController redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'You must be an admin to delete a registration.') end end + + helper_method :get_supporter_level end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 70ae48d0..c5adfc14 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -14,15 +14,6 @@ module ApplicationHelper var.strftime("%a, %d %b") end end - - def get_supporter_level(registration) - @conference.supporter_registrations.find_by_sql("SELECT *, supporter_levels.title as title - FROM supporter_registrations - INNER JOIN supporter_levels - ON supporter_registrations.supporter_level_id = supporter_levels.id - WHERE supporter_registrations.conference_id = #{@conference.id} - AND supporter_registrations.registration_id = #{registration.id}").first - end def add_association_link(association_name, form_builder, div_class, html_options = {}) link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(:class => "assoc btn btn-success") diff --git a/app/models/registration.rb b/app/models/registration.rb index 3c65d6c8..626b6022 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -4,6 +4,7 @@ class Registration < ActiveRecord::Base belongs_to :dietary_choice has_one :supporter_registration + has_one :supporter_level, :through => :supporter_registration has_and_belongs_to_many :social_events has_and_belongs_to_many :events @@ -20,4 +21,5 @@ class Registration < ActiveRecord::Base alias_attribute :social_events, :attending_social_events alias_attribute :need_access, :handicapped_access_required alias_attribute :other_needs, :other_special_needs + 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 c33ce7d6..3c7078d6 100644 --- a/app/views/admin/registrations/show.html.haml +++ b/app/views/admin/registrations/show.html.haml @@ -29,12 +29,10 @@ - @headers.each do |field| %td - if field == "name" - #{registration.last_name} #{registration.first_name} (#{registration.public_name}) - - supp_reg = get_supporter_level(registration) - - if supp_reg - %br + #{registration.last_name} #{registration.first_name} (#{registration.nickname}) #{registration.affiliation} + - if registration.supporter_level %p{:style => "color:red"} - = supp_reg.title unless supp_reg.title == "Free" + = registration.supporter_level.title unless registration.supporter_level.title == 'Free' -elsif field == 'attended' = link_to "#{registration.send(field.to_sym)}", admin_conference_registrations_change_field_path(@conference.short_title, :id => registration.id, :view_field => "#{field}"), :method => :put, ":#{field}" => registration.send(field.to_sym), :class => "btn btn-success"