From fe107076afed44859534d12ae77c3c284216ede0 Mon Sep 17 00:00:00 2001 From: Godwin Date: Sun, 27 Jul 2014 23:14:54 -0600 Subject: [PATCH] Registrations page --- app/assets/stylesheets/sass/_base.scss | 15 ++++ app/controllers/conferences_controller.rb | 24 +++--- app/views/conferences/registrations.html.haml | 81 +++++++++++++++++++ config/routes.rb | 1 + 4 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 app/views/conferences/registrations.html.haml diff --git a/app/assets/stylesheets/sass/_base.scss b/app/assets/stylesheets/sass/_base.scss index 117e8fd..bec6beb 100644 --- a/app/assets/stylesheets/sass/_base.scss +++ b/app/assets/stylesheets/sass/_base.scss @@ -491,3 +491,18 @@ ul.tags, } } } + +.workshop { + list-style: none; + overflow: auto; + + &:target { + background-color: $color-5; + } +} + +.registrations .user { + &:target { + background-color: $color-5; + } +} diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 493c915..ff8250d 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -2,7 +2,15 @@ require 'geocoder/calculations' require 'rest_client' class ConferencesController < ApplicationController - before_action :set_conference, only: [:show, :edit, :update, :destroy] + before_action :set_conference, only: [:show, :edit, :update, :destroy, :registrations] + before_filter :authenticate, only: [:registrations] + + def authenticate + auth = get_secure_info(:registrations_access) + authenticate_or_request_with_http_basic('Administration') do |username, password| + username == auth[:username] && password == auth[:password] + end + end # GET /conferences def index @@ -404,15 +412,6 @@ class ConferencesController < ApplicationController #end {error: false, next_step: params[:cancel] ? 'cancel' : next_step} end - - def workshop_test - set_conference - @register_step = 'new_workshop' - @register_template = 'register_new_workshop' - session[:registration] = {:workshop => [Hash.new]} - session[:registration][:workshop_index] = 0 - render 'show' - end def register is_post = request.post? || session[:registration_step] @@ -496,6 +495,11 @@ class ConferencesController < ApplicationController end end + def registrations + registrations = ConferenceRegistration.where(:conference_id => @conference.id) + @registrations = registrations + end + def register_confirm set_conference @conference_registration = ConferenceRegistration.find_by(confirmation_token: params[:confirmation_token]) diff --git a/app/views/conferences/registrations.html.haml b/app/views/conferences/registrations.html.haml new file mode 100644 index 0000000..085a780 --- /dev/null +++ b/app/views/conferences/registrations.html.haml @@ -0,0 +1,81 @@ +- location = @conference.organizations.first.locations.first +- location_name = location.city + ', ' + (location.territory ? Carmen::Country.coded(location.country).subregions.coded(location.territory).name : location.country) + +- title @conference.title +- description "#{@conference.title} conference in #{location_name} for DIY bicycle collectives, co-ops, and advocacy groups" += render 'header' +- stats = {confirmed: 0, completed: 0, total: 0, paid: 0, collected: 0} +%article.row + .columns.large-10 + %h2=_'conference.registrations.title','Registrations' + %table.registrations + %tr + %th='Email' + %th='First Name' + %th='Last Name' + %th='Preferred Name' + %th='Confirmed?' + %th='Completed?' + %th='Paid?' + - @registrations.each do |registration| + %tr + - data = YAML.load(registration.data) + - user = User.find_by(:email => registration.email) + - stats[:total] += 1 + - stats[:confirmed] += (registration.is_confirmed ? 1 : 0) + - stats[:completed] += (registration.completed ? 1 : 0) + - stats[:paid] += (registration.registration_fees_paid ? 1 : 0) + - stats[:collected] += (registration.registration_fees_paid || 0) + %td.user{rowspan: 2, id: user ? "user-#{user.id}" : nil}=registration.email + %td=data[:user][:firstname] + %td=data[:user][:lastname] + %td=data[:user][:username] + %td=registration.is_confirmed ? 'Yes' : 'No' + %td=registration.completed ? 'Yes' : 'No' + %td=registration.registration_fees_paid.nil? ? 'No' : 'Yes' + - if user.present? + %tr + %th='Organizations' + %td{colspan: 2} + - UserOrganizationRelationship.where(:user_id => user.id).each do |rel| + - org = Organization.find(rel.organization_id) + - location_name = "#{org.locations[0].city}, #{org.locations[0].territory}" + = link_to "#{org.name} (#{location_name})", org + %th='Workshops' + %td{colspan: 2} + - Workshop.where('workshop_facilitators.user_id' => user.id, :conference_id => @conference.id).joins(:workshop_facilitators).each do | workshop | + %a{href: "#workshop-#{workshop.slug}"}= workshop.title + + %h3=_'conference.registrations.workshops.title','Workshops' + %ul + - Workshop.where(:conference_id => @conference.id).each do |workshop| + %li.workshop{id: "workshop-#{workshop.slug}"} + .columns + %h4=workshop.title + .columns.medium-10.medium-offset-1.end + = workshop.info.html_safe + .columns.medium-8.medium-offset-2.end + %h5='Facilitators' + - workshop.workshop_facilitators.each do |facilitator| + - user = User.find(facilitator.user_id) + %div + %a{href: "#user-#{user.id}"}="#{user.username} (#{user.email})" + +- content_for :side_bar do + %h5='Stats' + %table + %tr + %th='Confirmed Registrations:' + %td=stats[:confirmed] + %tr + %th='Unconfirmed Registrations:' + %td=(stats[:total] - stats[:confirmed]) + %tr + %th='Completed Registrations:' + %td=stats[:completed] + %tr + %th='Incomplete Registrations:' + %td=(stats[:total] - stats[:completed]) + %tr + %th='Fees Collected:' + %td=number_to_currency(stats[:collected], :unit => '$') diff --git a/config/routes.rb b/config/routes.rb index 1a1b7a7..c7b58b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,7 @@ BikeBike::Application.routes.draw do match 'register/pay-registration/:confirmation_token' => 'conferences#register_pay_registration', via: [:get, :post] get 'register/paypal-confirm/:confirmation_token' => 'conferences#register_paypal_confirm' get 'register/paypal-cancel/:confirmation_token' => 'conferences#register_paypal_cancel' + get 'registrations' => 'conferences#registrations' #patch 'register/step/:step' => 'conferences#register_step' #resources :registrations, :path => 'registration' do # get :form, on: :collection