add pagination, re-arrange view
This commit is contained in:
parent
3ec3944406
commit
f53af55a74
4 changed files with 53 additions and 33 deletions
|
|
@ -5,11 +5,27 @@ class Admin::RegistrationsController < ApplicationController
|
||||||
session[:return_to] ||= request.referer
|
session[:return_to] ||= request.referer
|
||||||
@pdf_filename = "#{@conference.title}.pdf"
|
@pdf_filename = "#{@conference.title}.pdf"
|
||||||
@registrations = @conference.registrations.all(:joins => :person,
|
@registrations = @conference.registrations.all(:joins => :person,
|
||||||
:order => "people.last_name ASC",
|
:order => "registrations.created_at ASC",
|
||||||
:select => "registrations.*,
|
:select => "registrations.*,
|
||||||
people.last_name AS last_name,
|
people.last_name AS last_name,
|
||||||
people.first_name AS first_name,
|
people.first_name AS first_name,
|
||||||
people.public_name AS public_name,
|
people.public_name AS public_name,
|
||||||
people.email AS email")
|
people.email AS email")
|
||||||
|
|
||||||
|
@attended = @conference.registrations.where("attended = ?", true)
|
||||||
|
@headers = %w[attended name email social_events attending_with_partner need_access other_needs arrival departure]
|
||||||
|
end
|
||||||
|
|
||||||
|
def change_field
|
||||||
|
@registration = Registration.find(params[:id])
|
||||||
|
field = params[:view_field]
|
||||||
|
if @registration.send(field.to_sym)
|
||||||
|
@registration.update_attribute(:"#{field}",0)
|
||||||
|
else
|
||||||
|
@registration.update_attribute(:"#{field}",1)
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -15,4 +15,9 @@ class Registration < ActiveRecord::Base
|
||||||
accepts_nested_attributes_for :person
|
accepts_nested_attributes_for :person
|
||||||
accepts_nested_attributes_for :supporter_registration
|
accepts_nested_attributes_for :supporter_registration
|
||||||
accepts_nested_attributes_for :social_events
|
accepts_nested_attributes_for :social_events
|
||||||
end
|
|
||||||
|
alias_attribute :with_partner, :attending_with_partner
|
||||||
|
alias_attribute :social_events, :attending_social_events
|
||||||
|
alias_attribute :need_access, :handicapped_access_required
|
||||||
|
alias_attribute :other_needs, :other_special_needs
|
||||||
|
end
|
||||||
|
|
@ -9,45 +9,43 @@
|
||||||
Registrations
|
Registrations
|
||||||
- if @registrations
|
- if @registrations
|
||||||
= "(#{@registrations.length})"
|
= "(#{@registrations.length})"
|
||||||
%table.table.table-striped.table-bordered.table-hover
|
- if @attended
|
||||||
|
= " - Attended (#{@attended.length})"
|
||||||
|
%table.table.table-striped.table-bordered.table-hover#registrations
|
||||||
%thead
|
%thead
|
||||||
%th
|
%th
|
||||||
%b Last Name
|
No
|
||||||
%th
|
- @headers.each do |h|
|
||||||
%b First Name
|
- h = h.gsub("_", " ")
|
||||||
%th
|
%th
|
||||||
%b Public Name
|
= h.capitalize
|
||||||
%th
|
|
||||||
%b Email
|
|
||||||
%th
|
|
||||||
%b Attending Social Events
|
|
||||||
%th
|
|
||||||
%b Attending With Partner
|
|
||||||
%th
|
|
||||||
%b Arrival Date
|
|
||||||
%th
|
|
||||||
%b Departure Date
|
|
||||||
%th
|
%th
|
||||||
%th
|
%th
|
||||||
|
- counter = 0
|
||||||
- @registrations.each do |registration|
|
- @registrations.each do |registration|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
= registration.last_name
|
= counter +=1
|
||||||
%td
|
- @headers.each do |field|
|
||||||
= registration.first_name
|
%td
|
||||||
%td
|
- if field == "name"
|
||||||
= registration.public_name
|
#{registration.last_name} #{registration.first_name} (#{registration.public_name})
|
||||||
%td
|
|
||||||
= registration.email
|
-elsif (registration.send(field.to_sym).class == TrueClass || registration.send(field.to_sym).class == FalseClass)
|
||||||
%td
|
= 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)
|
||||||
= registration.attending_social_events
|
- elsif field == 'arrival' || field == 'departure'
|
||||||
%td
|
= registration.send(field.to_sym).strftime("%d %b %H:%M") if registration.send(field.to_sym)
|
||||||
= registration.attending_with_partner
|
- else
|
||||||
%td
|
= registration.send(field.to_sym)
|
||||||
= registration.arrival
|
|
||||||
%td
|
|
||||||
= registration.departure
|
|
||||||
%td
|
%td
|
||||||
= link_to "Edit", "#", :class => "btn btn-primary"
|
= link_to "Edit", "#", :class => "btn btn-primary"
|
||||||
%td
|
%td
|
||||||
= link_to "Delete", "#", :class => "btn btn-danger", :confirm => "Really delete registration for #{registration.public_name}?"
|
= link_to "Delete", "#", :class => "btn btn-danger", :confirm => "Really delete registration for #{registration.public_name}?"
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#registrations').dataTable( {
|
||||||
|
"bPaginate": false,
|
||||||
|
"bLengthChange": false
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
|
@ -10,6 +10,7 @@ Osem::Application.routes.draw do
|
||||||
get "/schedule" => "schedule#show"
|
get "/schedule" => "schedule#show"
|
||||||
put "/schedule" => "schedule#update"
|
put "/schedule" => "schedule#update"
|
||||||
get "/registrations" => "registrations#show"
|
get "/registrations" => "registrations#show"
|
||||||
|
put "/registrations/change_field" => "registrations#change_field"
|
||||||
get "/emailsettings" => "emails#show", :as => "email_settings"
|
get "/emailsettings" => "emails#show", :as => "email_settings"
|
||||||
put "/emailsettings" => "emails#update", :as => "email_settings"
|
put "/emailsettings" => "emails#update", :as => "email_settings"
|
||||||
get "/supporter_levels" => "SupporterLevels#show"
|
get "/supporter_levels" => "SupporterLevels#show"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue