This commit is contained in:
differentreality 2013-07-15 13:11:18 +03:00
parent 79ba3c5ea6
commit 7c834347f9
4 changed files with 9 additions and 16 deletions

View file

@ -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
@ -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

View file

@ -15,15 +15,6 @@ module ApplicationHelper
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")
end

View file

@ -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

View file

@ -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"