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") people.email AS email, people.company as affiliation, people.irc_nickname as nickname")
@attended = @conference.registrations.where("attended = ?", true) @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 end
def change_field def change_field
@ -28,7 +28,7 @@ class Admin::RegistrationsController < ApplicationController
redirect_to admin_conference_registrations_path(@conference.short_title, @registration) 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}" flash[:notice] = "Updated '#{params[:view_field]}' for #{(Person.where("id = ?", @registration.person_id).first).email}"
end end
def edit def edit
@registration = @conference.registrations.where("id = ?", params[:id]).first @registration = @conference.registrations.where("id = ?", params[:id]).first
@person = Person.where("id = ?", @registration.person_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.') redirect_to(admin_conference_registrations_path(@conference.short_title), :alert => 'You must be an admin to delete a registration.')
end end
end end
helper_method :get_supporter_level
end end

View file

@ -14,15 +14,6 @@ module ApplicationHelper
var.strftime("%a, %d %b") var.strftime("%a, %d %b")
end end
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 = {}) 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") link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(:class => "assoc btn btn-success")

View file

@ -4,6 +4,7 @@ class Registration < ActiveRecord::Base
belongs_to :dietary_choice belongs_to :dietary_choice
has_one :supporter_registration has_one :supporter_registration
has_one :supporter_level, :through => :supporter_registration
has_and_belongs_to_many :social_events has_and_belongs_to_many :social_events
has_and_belongs_to_many :events has_and_belongs_to_many :events
@ -20,4 +21,5 @@ class Registration < ActiveRecord::Base
alias_attribute :social_events, :attending_social_events alias_attribute :social_events, :attending_social_events
alias_attribute :need_access, :handicapped_access_required alias_attribute :need_access, :handicapped_access_required
alias_attribute :other_needs, :other_special_needs alias_attribute :other_needs, :other_special_needs
end end

View file

@ -29,12 +29,10 @@
- @headers.each do |field| - @headers.each do |field|
%td %td
- if field == "name" - if field == "name"
#{registration.last_name} #{registration.first_name} (#{registration.public_name}) #{registration.last_name} #{registration.first_name} (#{registration.nickname}) #{registration.affiliation}
- supp_reg = get_supporter_level(registration) - if registration.supporter_level
- if supp_reg
%br
%p{:style => "color:red"} %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' -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" = 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"