Check in and some other improvements
This commit is contained in:
@@ -84,6 +84,30 @@ class ConferenceAdministrationController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def check_in
|
||||
set_conference
|
||||
return do_403 unless @this_conference.host? current_user
|
||||
|
||||
@page_title_vars = { title: @this_conference.title }
|
||||
@admin_step = :check_in
|
||||
@admin_group = view_context.get_administration_group(@admin_step)
|
||||
|
||||
if params[:id] =~ /^\S+@\S+\.\S{2,}$/
|
||||
@user = User.new(email: params[:id])
|
||||
elsif params[:id] =~ /^\d+$/
|
||||
@user = User.find(params[:id].to_i)
|
||||
else
|
||||
return do_404
|
||||
end
|
||||
|
||||
@registration = @this_conference.registration_for(@user) || ConferenceRegistration.new(conference: @this_conference)
|
||||
@registration.data ||= {}
|
||||
|
||||
@user_name = @user.firstname || 'this person'
|
||||
@user_name_proper = @user.firstname || 'This person'
|
||||
@user_name_for_title = @user.firstname || "<em>#{@user.email}</em>"
|
||||
end
|
||||
|
||||
rescue_from ActiveRecord::PremissionDenied do |exception|
|
||||
do_403
|
||||
end
|
||||
@@ -199,7 +223,7 @@ class ConferenceAdministrationController < ApplicationController
|
||||
name: org.name,
|
||||
street_address: address.present? ? address.street : nil,
|
||||
city: address.present? ? address.city : nil,
|
||||
subregion: address.present? ? I18n.t("geography.subregions.#{address.country}.#{address.territory}") : nil,
|
||||
subregion: address.present? ? I18n.t("geography.subregions.#{address.country}.#{address.territory}", resolve: false) : nil,
|
||||
country: address.present? ? I18n.t("geography.countries.#{address.country}") : nil,
|
||||
postal_code: address.present? ? address.postal_code : nil,
|
||||
email: org.email_address,
|
||||
@@ -299,6 +323,46 @@ class ConferenceAdministrationController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def administrate_check_in
|
||||
sort_weight = {
|
||||
checked_in: 5,
|
||||
registered: 4,
|
||||
incomplete: 3,
|
||||
cancelled: 2,
|
||||
unregistered: 1
|
||||
}
|
||||
|
||||
@registration_data = []
|
||||
User.all.each do |user|
|
||||
if user.email.present?
|
||||
new_data = {
|
||||
user_id: user.id,
|
||||
email: user.email,
|
||||
name: user.firstname
|
||||
}
|
||||
|
||||
organization = user.organizations.first
|
||||
new_data[:organization] = organization.present? ? organization.name : ''
|
||||
|
||||
registration = @this_conference.registration_for(user)
|
||||
if registration.present? && registration.city_id.present?
|
||||
new_data[:location] = registration.city.to_s
|
||||
status = registration.status
|
||||
else
|
||||
new_data[:location] = user.last_location.to_s
|
||||
status = :unregistered
|
||||
end
|
||||
|
||||
new_data[:status] = I18n.t("articles.conference_registration.terms.registration_status.#{status}")
|
||||
new_data[:sort_weight] = sort_weight[status]
|
||||
|
||||
@registration_data << new_data
|
||||
end
|
||||
end
|
||||
|
||||
@registration_data.sort! { |a, b| b[:sort_weight] <=> a[:sort_weight] }
|
||||
end
|
||||
|
||||
def administrate_stats
|
||||
if @this_conference.start_date.blank? || @this_conference.end_date.blank?
|
||||
@warning_message = :no_date_warning
|
||||
@@ -476,6 +540,7 @@ class ConferenceAdministrationController < ApplicationController
|
||||
@excel_data = {
|
||||
columns: [
|
||||
:name,
|
||||
:pronoun,
|
||||
:email,
|
||||
:date,
|
||||
:status,
|
||||
@@ -524,6 +589,7 @@ class ConferenceAdministrationController < ApplicationController
|
||||
},
|
||||
keys: {
|
||||
name: 'forms.labels.generic.name',
|
||||
pronoun: 'forms.labels.generic.pronoun',
|
||||
email: 'forms.labels.generic.email',
|
||||
status: 'forms.labels.generic.registration_status',
|
||||
is_attending: 'articles.conference_registration.terms.is_attending',
|
||||
@@ -590,6 +656,7 @@ class ConferenceAdministrationController < ApplicationController
|
||||
data = {
|
||||
id: r.id,
|
||||
name: user.firstname || '',
|
||||
pronoun: user.pronoun || '',
|
||||
email: user.email || '',
|
||||
status: I18n.t("articles.conference_registration.terms.registration_status.#{view_context.registration_status(r)}"),
|
||||
is_attending: I18n.t("articles.conference_registration.questions.bike.#{r.is_attending == 'n' ? 'no' : 'yes'}"),
|
||||
@@ -1101,6 +1168,9 @@ class ConferenceAdministrationController < ApplicationController
|
||||
# delete deprecated values
|
||||
registration.allergies = nil
|
||||
registration.other = nil
|
||||
when :org_non_member_interest
|
||||
registration.data ||= {}
|
||||
registration.data['non_member_interest'] = value
|
||||
when :registration_fees_paid
|
||||
registration.data ||= {}
|
||||
registration.data['payment_amount'] = value.to_f
|
||||
@@ -1116,8 +1186,8 @@ class ConferenceAdministrationController < ApplicationController
|
||||
registration.housing_data['companion'] ||= {}
|
||||
registration.housing_data['companion']['email'] = value
|
||||
registration.housing_data['companion']['id'] = User.find_user(value).id
|
||||
when :preferred_language
|
||||
registration.user.locale = value
|
||||
when :preferred_language, :pronoun
|
||||
registration.user.send("#{key}=", value)
|
||||
user_changed = true
|
||||
when :is_subscribed
|
||||
registration.user.is_subscribed = (value != "false")
|
||||
@@ -1180,6 +1250,67 @@ class ConferenceAdministrationController < ApplicationController
|
||||
return nil
|
||||
end
|
||||
|
||||
def admin_update_check_in
|
||||
unless params[:button] == 'cancel'
|
||||
user_id = params[:user_id]
|
||||
|
||||
if params[:user_id].present?
|
||||
user_id = user_id.to_i
|
||||
else
|
||||
user_id = User.get(params[:email]).id
|
||||
end
|
||||
|
||||
registration = ConferenceRegistration.where(
|
||||
user_id: user_id,
|
||||
conference_id: @this_conference.id
|
||||
).limit(1).first ||
|
||||
ConferenceRegistration.new(
|
||||
conference_id: @this_conference.id,
|
||||
user_id: user_id
|
||||
)
|
||||
|
||||
registration.data ||= {}
|
||||
registration.data['checked_in'] ||= DateTime.now
|
||||
|
||||
if params[:payment]
|
||||
amount = params[:payment].to_f
|
||||
if amount > 0
|
||||
registration.registration_fees_paid ||= 0
|
||||
registration.registration_fees_paid += amount
|
||||
registration.data['payment_amount'] = amount
|
||||
registration.data['payment_currency'] ||= params[:currency]
|
||||
end
|
||||
end
|
||||
|
||||
user = nil
|
||||
if params[:name].present?
|
||||
user ||= registration.user
|
||||
user.firstname ||= params[:name]
|
||||
end
|
||||
|
||||
if params[:pronoun].present?
|
||||
user ||= registration.user
|
||||
user.pronoun ||= params[:pronoun]
|
||||
end
|
||||
|
||||
if params[:location].present?
|
||||
unless registration.city_id.present?
|
||||
city = City.search(params[:location])
|
||||
registration.city_id = city.id if city.present?
|
||||
end
|
||||
end
|
||||
|
||||
user.save if user.present?
|
||||
|
||||
registration.bike = params[:bike]
|
||||
registration.data['programme'] = params[:programme]
|
||||
|
||||
registration.save
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
def admin_update_housing
|
||||
# modify the guest data
|
||||
if params[:button] == 'get-guest-list'
|
||||
|
||||
@@ -104,297 +104,6 @@ class ConferencesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def old_register
|
||||
set_conference
|
||||
|
||||
@register_template = nil
|
||||
|
||||
if logged_in?
|
||||
set_or_create_conference_registration
|
||||
|
||||
@name = current_user.firstname
|
||||
# we should phase out last names
|
||||
@name += " #{current_user.lastname}" if current_user.lastname
|
||||
|
||||
@name ||= current_user.username
|
||||
|
||||
@is_host = @this_conference.host? current_user
|
||||
else
|
||||
@register_template = :confirm_email
|
||||
end
|
||||
|
||||
steps = nil
|
||||
return do_404 unless registration_steps.present?
|
||||
|
||||
# @register_template = :administration if params[:admin_step].present?
|
||||
|
||||
@errors = {}
|
||||
@warnings = []
|
||||
form_step = params[:button] ? params[:button].to_sym : nil
|
||||
|
||||
# process any data that was passed to us
|
||||
if form_step
|
||||
if form_step.to_s =~ /^prev_(.+)$/
|
||||
steps = registration_steps
|
||||
@register_template = steps[steps.find_index($1.to_sym) - 1]
|
||||
elsif form_step == :paypal_confirm
|
||||
if @registration.present? && @registration.payment_confirmation_token == params[:confirmation_token]
|
||||
if Rails.env.test?
|
||||
@amount = params[:amount].to_f
|
||||
info = YAML.load(@registration.payment_info)
|
||||
info[:amount] = @amount
|
||||
@registration.payment_info = info.to_yaml
|
||||
else
|
||||
@amount = PayPal!.details(params[:token]).amount.total
|
||||
@registration.payment_info = {
|
||||
payer_id: params[:PayerID],
|
||||
token: params[:token],
|
||||
amount: @amount
|
||||
}.to_yaml
|
||||
end
|
||||
|
||||
@amount = (@amount * 100).to_i.to_s.gsub(/^(.*)(\d\d)$/, '\1.\2')
|
||||
|
||||
@registration.save!
|
||||
end
|
||||
|
||||
@page_title = 'articles.conference_registration.headings.Payment'
|
||||
@register_template = :paypal_confirm
|
||||
elsif form_step == :paypal_confirmed
|
||||
info = YAML.load(@registration.payment_info)
|
||||
@amount = nil
|
||||
status = nil
|
||||
if Rails.env.test?
|
||||
status = info[:status]
|
||||
@amount = info[:amount]
|
||||
else
|
||||
paypal = PayPal!.checkout!(info[:token], info[:payer_id], PayPalRequest(info[:amount]))
|
||||
status = paypal.payment_info.first.payment_status
|
||||
@amount = paypal.payment_info.first.amount.total
|
||||
end
|
||||
if status == 'Completed'
|
||||
@registration.registration_fees_paid ||= 0
|
||||
@registration.registration_fees_paid += @amount
|
||||
|
||||
# don't complete the step unless fees have been paid
|
||||
if @registration.registration_fees_paid > 0
|
||||
@registration.steps_completed << :payment
|
||||
@registration.steps_completed.uniq!
|
||||
end
|
||||
|
||||
@registration.save!
|
||||
else
|
||||
@errors[:payment] = :incomplete
|
||||
@register_template = :payment
|
||||
end
|
||||
@page_title = 'articles.conference_registration.headings.Payment'
|
||||
else
|
||||
|
||||
case form_step
|
||||
when :confirm_email
|
||||
return confirm_email(params[:email], params[:token], register_path(@this_conference.slug))
|
||||
when :contact_info
|
||||
if params[:name].present? && params[:name].gsub(/[\s\W]/, '').present?
|
||||
current_user.firstname = params[:name].squish
|
||||
current_user.lastname = nil
|
||||
else
|
||||
@errors[:name] = :empty
|
||||
end
|
||||
|
||||
if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present?
|
||||
city = City.search(params[:location])
|
||||
|
||||
if city.present?
|
||||
@registration.city_id = city.id
|
||||
if params[:location].gsub(/[\s,]/, '').downcase != view_context.location(city).gsub(/[\s,]/, '').downcase
|
||||
@warnings << view_context._('warnings.messages.location_corrected', vars: {original: params[:location], corrected: view_context.location(city)})
|
||||
end
|
||||
else
|
||||
@errors[:location] = :unknown
|
||||
end
|
||||
else
|
||||
@errors[:location] = :empty
|
||||
end
|
||||
|
||||
if params[:languages].present?
|
||||
current_user.languages = params[:languages].keys
|
||||
else
|
||||
@errors[:languages] = :empty
|
||||
end
|
||||
|
||||
current_user.save! unless @errors.present?
|
||||
when :hosting
|
||||
@registration.can_provide_housing = params[:can_provide_housing].present?
|
||||
if params[:not_attending]
|
||||
@registration.is_attending = 'n'
|
||||
|
||||
if current_user.is_subscribed.nil?
|
||||
current_user.is_subscribed = false
|
||||
current_user.save!
|
||||
end
|
||||
else
|
||||
@registration.is_attending = 'y'
|
||||
end
|
||||
|
||||
@registration.housing_data = {
|
||||
address: params[:address],
|
||||
phone: params[:phone],
|
||||
space: {
|
||||
bed_space: params[:bed_space],
|
||||
floor_space: params[:floor_space],
|
||||
tent_space: params[:tent_space],
|
||||
},
|
||||
considerations: (params[:considerations] || {}).keys,
|
||||
availability: [ params[:first_day], params[:last_day] ],
|
||||
notes: params[:notes]
|
||||
}
|
||||
when :questions
|
||||
# create the companion's user account and send a registration link unless they have already registered
|
||||
generate_confirmation(User.create(email: params[:companion]), register_path(@this_conference.slug)) if params[:companion].present? && User.find_user(params[:companion]).nil?
|
||||
|
||||
@registration.housing = params[:housing]
|
||||
@registration.arrival = params[:arrival]
|
||||
@registration.departure = params[:departure]
|
||||
@registration.housing_data = {
|
||||
companions: [ params[:companion] ]
|
||||
}
|
||||
@registration.bike = params[:bike]
|
||||
@registration.food = params[:food]
|
||||
@registration.allergies = params[:allergies]
|
||||
@registration.other = params[:other]
|
||||
when :payment
|
||||
amount = params[:amount].to_f
|
||||
|
||||
if amount > 0
|
||||
# we can't really test paypal integration in our tests, so we'll fake it instead
|
||||
if Rails.env.test?
|
||||
@registration.payment_confirmation_token = 'token'
|
||||
@registration.payment_info = {amount: amount}.to_yaml
|
||||
@registration.save!
|
||||
redirect_to 'https://www.paypal.com'
|
||||
else
|
||||
@registration.payment_confirmation_token = Digest::SHA256.hexdigest(rand(Time.now.to_f * 1000000).to_i.to_s)
|
||||
@registration.save!
|
||||
pp = PayPal!
|
||||
response = pp.setup(
|
||||
PayPalRequest(amount),
|
||||
register_paypal_confirm_url(@this_conference.slug, :paypal_confirm, @registration.payment_confirmation_token),
|
||||
register_paypal_confirm_url(@this_conference.slug, :paypal_cancel, @registration.payment_confirmation_token),
|
||||
noshipping: true,
|
||||
version: 204
|
||||
)
|
||||
redirect_to response.redirect_uri
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if @errors.present?
|
||||
@register_template = form_step
|
||||
else
|
||||
unless @registration.nil?
|
||||
steps = registration_steps
|
||||
step_index = steps.find_index(form_step)
|
||||
@register_template = steps[step_index + 1] if step_index.present?
|
||||
|
||||
# have we reached a new level?
|
||||
unless @registration.steps_completed.include? form_step.to_s
|
||||
# this step is only completed if a payment has been made
|
||||
if form_step != :payment || (@registration.registration_fees_paid || 0) > 0
|
||||
@registration.steps_completed ||= []
|
||||
@registration.steps_completed << form_step.to_s
|
||||
@registration.steps_completed.uniq!
|
||||
end
|
||||
end
|
||||
|
||||
@registration.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
steps ||= registration_steps
|
||||
|
||||
# make sure we're on a valid step
|
||||
@register_template ||= (params[:step] || view_context.current_step).to_sym
|
||||
|
||||
if logged_in? && @register_template != :paypal_confirm
|
||||
# if we're logged in
|
||||
if !steps.include?(@register_template)
|
||||
# and we are not viewing a valid step
|
||||
return redirect_to register_path(@this_conference.slug)
|
||||
elsif @register_template != view_context.current_step && !registration_complete? && !@registration.steps_completed.include?(@register_template.to_s)
|
||||
# or the step hasn't been reached, registration is not yet complete, and we're not viewing the latest incomplete step
|
||||
return redirect_to register_path(@this_conference.slug)
|
||||
end
|
||||
# then we'll redirect to the current registration step
|
||||
end
|
||||
|
||||
# prepare the form
|
||||
case @register_template
|
||||
when :questions
|
||||
# see if someone else has asked to be your companion
|
||||
if @registration.housing_data.blank?
|
||||
ConferenceRegistration.where(
|
||||
conference_id: @this_conference.id, can_provide_housing: [nil, false]
|
||||
).where.not(housing_data: nil).each do |r|
|
||||
@registration.housing_data = {
|
||||
companions: [ r.user.email ]
|
||||
} if r.housing_data['companion'].present? && (r.housing_data['companion']['id'] == current_user.id || r.housing_data['companion']['email'] == current_user.email)
|
||||
end
|
||||
|
||||
@registration.housing_data ||= { }
|
||||
end
|
||||
@page_title = 'articles.conference_registration.headings.Registration_Info'
|
||||
when :payment
|
||||
@page_title = 'articles.conference_registration.headings.Payment'
|
||||
when :workshops
|
||||
@page_title = 'articles.conference_registration.headings.Workshops'
|
||||
|
||||
# initialize our arrays
|
||||
@my_workshops = Array.new
|
||||
@requested_workshops = Array.new
|
||||
@workshops_in_need = Array.new
|
||||
@workshops = Array.new
|
||||
|
||||
# put wach workshop into the correct array
|
||||
Workshop.where(conference_id: @this_conference.id).each do |workshop|
|
||||
if workshop.active_facilitator?(current_user)
|
||||
@my_workshops << workshop
|
||||
elsif workshop.requested_collaborator?(current_user)
|
||||
@requested_workshops << workshop
|
||||
elsif workshop.needs_facilitators
|
||||
@workshops_in_need << workshop
|
||||
else
|
||||
@workshops << workshop
|
||||
end
|
||||
end
|
||||
|
||||
# sort the arrays by name
|
||||
@my_workshops.sort! { |a, b| a.title.downcase <=> b.title.downcase }
|
||||
@requested_workshops.sort! { |a, b| a.title.downcase <=> b.title.downcase }
|
||||
@workshops_in_need.sort! { |a, b| a.title.downcase <=> b.title.downcase }
|
||||
@workshops.sort! { |a, b| a.title.downcase <=> b.title.downcase }
|
||||
when :contact_info
|
||||
@page_title = 'articles.conference_registration.headings.Contact_Info'
|
||||
when :hosting
|
||||
@page_title = 'articles.conference_registration.headings.Hosting'
|
||||
@hosting_data = @registration.housing_data || {}
|
||||
@hosting_data['space'] ||= Hash.new
|
||||
@hosting_data['availability'] ||= Array.new
|
||||
@hosting_data['considerations'] ||= Array.new
|
||||
when :policy
|
||||
@page_title = 'articles.conference_registration.headings.Policy_Agreement'
|
||||
when :confirm_email
|
||||
@page_title = "articles.conference_registration.headings.#{@this_conference.registration_status == :open ? '': 'Pre_'}Registration_Details"
|
||||
@main_title = "articles.conference_registration.headings.#{@this_conference.registration_status == :open ? '': 'Pre_'}Register"
|
||||
@main_title_vars = { vars: { title: @this_conference.title } }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# helper_method :registration_steps
|
||||
# helper_method :current_registration_steps
|
||||
helper_method :registration_complete?
|
||||
|
||||
def registration_steps(conference = nil)
|
||||
|
||||
@@ -2,7 +2,7 @@ class WorkshopsController < ApplicationController
|
||||
|
||||
def workshops
|
||||
set_conference
|
||||
set_conference_registration!
|
||||
set_conference_registration
|
||||
@workshops = Workshop.where(conference_id: @this_conference.id)
|
||||
@my_workshops = @workshops.select { |w| w.active_facilitator?(current_user) }
|
||||
render 'workshops/index'
|
||||
@@ -10,7 +10,7 @@ class WorkshopsController < ApplicationController
|
||||
|
||||
def view_workshop
|
||||
set_conference
|
||||
set_conference_registration!
|
||||
set_conference_registration
|
||||
@workshop = Workshop.find_by_id_and_conference_id(params[:workshop_id], @this_conference.id)
|
||||
return do_404 unless @workshop
|
||||
|
||||
|
||||
Reference in New Issue
Block a user