Browse Source

Fixed registration emails and modified the schedule

development
Godwin 8 years ago
parent
commit
0770fd28e8
  1. 19
      app/assets/stylesheets/_application.scss
  2. 2
      app/controllers/application_controller.rb
  3. 14
      app/controllers/conferences_controller.rb
  4. 5
      app/helpers/application_helper.rb
  5. 44
      app/models/conference_registration.rb
  6. 4
      app/models/user.rb
  7. 11
      app/views/conferences/admin/_schedule.html.haml

19
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;
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 {
#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%);
}
}
}
}
&.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 {

2
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

14
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!

5
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)

44
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

4
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

11
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

Loading…
Cancel
Save