From 0770fd28e89c45872acd30901c07e34f29079b3d Mon Sep 17 00:00:00 2001 From: Godwin Date: Wed, 21 Sep 2016 21:37:16 -0700 Subject: [PATCH] Fixed registration emails and modified the schedule --- app/assets/stylesheets/_application.scss | 29 +++++++----- app/controllers/application_controller.rb | 2 +- app/controllers/conferences_controller.rb | 14 +++--- app/helpers/application_helper.rb | 5 +-- app/models/conference_registration.rb | 44 +++++++++++++++++++ app/models/user.rb | 4 ++ .../conferences/admin/_schedule.html.haml | 11 +---- 7 files changed, 77 insertions(+), 32 deletions(-) diff --git a/app/assets/stylesheets/_application.scss b/app/assets/stylesheets/_application.scss index d8398fc..56b033a 100644 --- a/app/assets/stylesheets/_application.scss +++ b/app/assets/stylesheets/_application.scss @@ -2201,6 +2201,10 @@ table.schedule { width: 100%; margin: 0 0 1em; + tbody { + border: 0.1rem solid #EEE; + } + &.locations-1 td.workshop.filled { width: 100%; } @@ -2225,38 +2229,39 @@ table.schedule { width: 16.66667%; } td { - //position: relative; text-align: center; - - &.empty { - border-top: 0; - border-bottom: 0; - background-color: #F8F8F8; - } + border: 0; + background-color: #F8F8F8; &.workshop { - background-color: lighten($colour-1, 40%); &.filled { background-color: lighten($colour-1, 25%); + border: 0.1rem solid #EEE; } &.open { - cursor: pointer; - white-space: nowrap; + #admin-schedule & { + background-color: lighten($colour-1, 40%); + cursor: pointer; + white-space: nowrap; + border: 0.1rem solid #EEE; - &:hover { - background-color: lighten($colour-1, 25%); + &:hover { + background-color: lighten($colour-1, 25%); + } } } } &.event { background-color: lighten($colour-2, 25%); + border: 0.1rem solid #EEE; } &.meal { background-color: lighten($colour-3, 25%); + border: 0.1rem solid #EEE; } .title { diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 18a636e..a785901 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -635,7 +635,7 @@ class ApplicationController < LinguaFrancaApplicationController } unless amenities.include? need end - @schedule[day][:times][time][:item][:workshops][ids[i]][:status][:conflict_score] = workshop_i.interested.present? ? (conflicts.length / workshop_i.interested.size) : 0 + @schedule[day][:times][time][:item][:workshops][ids[i]][:status][:conflict_score] = (conflicts || []).length end end end diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index b3d004c..eed7f29 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -201,13 +201,13 @@ class ConferencesController < ApplicationController end # workshops is the last step - if @register_template == :workshops - UserMailer.send_mail :registration_confirmation do - { - :args => @registration - } - end - end + # if @register_template == :workshops + # UserMailer.send_mail :registration_confirmation do + # { + # :args => @registration + # } + # end + # end end @registration.save! diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bbbe0d8..c6fc597 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -244,9 +244,8 @@ module ApplicationHelper end def registration_status(registration) - return :unregistered if registration.nil? || registration.user.firstname.blank? || registration.city.blank? - return :registered if registration.housing.present? || (registration.can_provide_housing && registration.housing_data.present? && registration.housing_data['availability'].present?) - return :preregistered + return :unregistered if registration.nil? + return registration.status end def sortable(objects, id = 'id', url: nil, &block) diff --git a/app/models/conference_registration.rb b/app/models/conference_registration.rb index 573e798..31ea194 100644 --- a/app/models/conference_registration.rb +++ b/app/models/conference_registration.rb @@ -28,4 +28,48 @@ class ConferenceRegistration < ActiveRecord::Base def self.all_considerations [:vegan, :smoking, :pets, :quiet] end + + def status(was = false) + return :unregistered if user.firstname.blank? || self.send(was ? :city_was : :city).blank? + return :registered if self.send(was ? :housing_was : :housing).present? || (self.send(was ? :can_provide_housing_was : :can_provide_housing) && (self.send(was ? :housing_data_was : :housing_data) || {})['availability'].present?) + return :preregistered + end + + around_update :check_status + + def check_status + yield #saves + old_status = status(true) + new_status = status + + puts " ===== #{old_status.to_s} : #{new_status.to_s} ==> #{conference.registration_status} ===== " + if old_status.present? && old_status != new_status + if (conference.registration_status == :pre && new_status == :preregistered) || + (conference.registration_status == :open && new_status == :registered) + + UserMailer.send_mail :registration_confirmation do + { + :args => self + } + end + end + end + end + + # before_update do | registration | + # old_status = status + # new_status = registration.status + # puts " ===== #{old_status.to_s} : #{new_status.to_s} ===== " + # if old_status.present? && old_status != new_status + # if (conference.registration_status == :pre && new_status == :preregistered) || + # (conference.registration_status == :open && new_status == :registered) + # end + + # UserMailer.send_mail :registration_confirmation do + # { + # :args => registration + # } + # end + # end + # end end diff --git a/app/models/user.rb b/app/models/user.rb index b6c633f..df4e5d2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -12,6 +12,10 @@ class User < ActiveRecord::Base has_many :authentications, :dependent => :destroy accepts_nested_attributes_for :authentications + before_update do |user| + user.locale ||= I18n.locale + end + before_save do |user| user.locale ||= I18n.locale end diff --git a/app/views/conferences/admin/_schedule.html.haml b/app/views/conferences/admin/_schedule.html.haml index 8be059e..f87ed6f 100644 --- a/app/views/conferences/admin/_schedule.html.haml +++ b/app/views/conferences/admin/_schedule.html.haml @@ -22,7 +22,6 @@ %th.corner - data[:locations].each do | id, location | %th=location.is_a?(Symbol) ? '' : location.title - %th.status %tbody - data[:times].each do | time, time_data | %tr @@ -50,8 +49,8 @@ = form_tag administration_update_path(conference.slug, :schedule), class: 'deschedule-workshop' do .status .conflict-score - %span.title Conflict Score: - %span.value="#{status[:conflict_score] * 100.0}%" + %span.title Conflicts: + %span.value="#{status[:conflict_score]} / #{workshop.interested.size}" - if status[:errors].present? .errors - status[:errors].each do | error | @@ -60,11 +59,6 @@ = button_tag :deschedule, value: :deschedule_workshop, class: [:delete, :small] - elsif @can_edit .title="Block #{time_data[:item][:block] + 1}" - %td.status{rowspan: rowspan} - - if time_data[:status].present? && time_data[:status][:errors].present? - %ul.errors - - time_data[:status][:errors].each do | error | - %li=error.to_json.to_s - elsif time_data[:type] != :nil %td{class: time_data[:type], rowspan: rowspan, colspan: data[:locations].present? ? data[:locations].size : 1} - case time_data[:type] @@ -92,7 +86,6 @@ = time_data[:item].event_location.title + _!(': ') = location_link time_data[:item].event_location = richtext time_data[:item][:info], 1 - %td.status{rowspan: rowspan} - if @entire_page #workshop-selector = form_tag administration_update_path(@this_conference.slug, :schedule), class: 'workshop-dlg', id: 'workshop-table-form' do