hound fixes
This commit is contained in:
parent
e8990bfb12
commit
fc753282d3
14 changed files with 180 additions and 144 deletions
|
|
@ -5,7 +5,8 @@ module Admin
|
||||||
def index
|
def index
|
||||||
session[:return_to] ||= request.referer
|
session[:return_to] ||= request.referer
|
||||||
@pdf_filename = "#{@conference.title}.pdf"
|
@pdf_filename = "#{@conference.title}.pdf"
|
||||||
@registrations = @conference.registrations.includes(:user).order('registrations.created_at ASC')
|
@registrations = @conference.registrations.includes(:user)
|
||||||
|
@registrations = @registrations.order('registrations.created_at ASC')
|
||||||
@attended = @conference.registrations.where('attended = ?', true).count
|
@attended = @conference.registrations.where('attended = ?', true).count
|
||||||
@headers = %w(name email nickname other_needs arrival departure attended)
|
@headers = %w(name email nickname other_needs arrival departure attended)
|
||||||
end
|
end
|
||||||
|
|
@ -36,7 +37,8 @@ module Admin
|
||||||
@user.update_attributes!(params[:registration][:user_attributes])
|
@user.update_attributes!(params[:registration][:user_attributes])
|
||||||
params[:registration].delete :user_attributes
|
params[:registration].delete :user_attributes
|
||||||
if params[:registration][:supporter_registration]
|
if params[:registration][:supporter_registration]
|
||||||
@registration.supporter_registration.update_attributes(params[:registration][:supporter_registration_attributes])
|
@registration.supporter_registration.
|
||||||
|
update_attributes(params[:registration][:supporter_registration_attributes])
|
||||||
params[:registration].delete :supporter_registration_attributes
|
params[:registration].delete :supporter_registration_attributes
|
||||||
end
|
end
|
||||||
@registration.update_attributes!(params[:registration])
|
@registration.update_attributes!(params[:registration])
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,31 @@ module Admin
|
||||||
before_filter :verify_organizer
|
before_filter :verify_organizer
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@registrations = @conference.registrations.includes(:user).order('registrations.created_at ASC')
|
@registrations = @conference.registrations.includes(:user)
|
||||||
|
@registrations = @registrations.order('registrations.created_at ASC')
|
||||||
@registered = @conference.registrations.count
|
@registered = @conference.registrations.count
|
||||||
@attendees = @conference.registrations.where('attended = ?', true).count
|
@attendees = @conference.registrations.where('attended = ?', true).count
|
||||||
@pre_registered = @conference.registrations.where('created_at < ?', @conference.start_date).count
|
@pre_registered = @conference.registrations
|
||||||
@pre_registered_attended = @conference.registrations.where('created_at < ? AND attended = ?', @conference.start_date, true).count
|
@pre_registered = @pre_registered.where('created_at < ?', @conference.start_date).count
|
||||||
|
@pre_registered_attended = @conference.registrations.where('created_at < ? AND attended = ?',
|
||||||
|
@conference.start_date, true).count
|
||||||
|
|
||||||
@registered_with_partner = @conference.registrations.where('attending_with_partner = ?', true).count
|
@registered_with_partner = @conference.registrations.where('attending_with_partner = ?',
|
||||||
@attended_with_partner = @conference.registrations.where('attending_with_partner = ? AND attended = ?', true, true).count
|
true).count
|
||||||
|
@attended_with_partner = @conference.registrations.where(
|
||||||
|
'attending_with_partner = ? AND attended = ?', true, true).count
|
||||||
|
|
||||||
@handicapped_access = @conference.registrations.where(handicapped_access_required: true).count
|
@handicapped_access = @conference.registrations.where(handicapped_access_required: true).count
|
||||||
@handicapped_access_attended = @conference.registrations.where(handicapped_access_required: true)
|
@handicapped_access_attended = @conference.registrations.where(handicapped_access_required:
|
||||||
|
true)
|
||||||
@handicapped_access_attended = @handicapped_access_attended.where(attended: true).count
|
@handicapped_access_attended = @handicapped_access_attended.where(attended: true).count
|
||||||
@suggested_hotel_stay = @conference.registrations.where('using_affiliated_lodging = ?', true).count
|
@suggested_hotel_stay = @conference.registrations.where('using_affiliated_lodging = ?',
|
||||||
|
true).count
|
||||||
|
|
||||||
@events = @conference.events
|
@events = @conference.events
|
||||||
# Events charts
|
# Events charts
|
||||||
@machine_states = [['confirmed'], ['cancelled'], ['rejected'], ['withdrawn'], ['new', 'review'], ['unconfirmed', 'accepted']]
|
@machine_states = [['confirmed'], ['cancelled'], ['rejected'], ['withdrawn'],
|
||||||
|
['new', 'review'], ['unconfirmed', 'accepted']]
|
||||||
# Types distribution per state
|
# Types distribution per state
|
||||||
@type_state = {}
|
@type_state = {}
|
||||||
@machine_states.each do |state|
|
@machine_states.each do |state|
|
||||||
|
|
@ -40,7 +48,7 @@ module Admin
|
||||||
if @events.count > 0
|
if @events.count > 0
|
||||||
start_date = @events.minimum('created_at').strftime('%Y-%m-%d')
|
start_date = @events.minimum('created_at').strftime('%Y-%m-%d')
|
||||||
end_date = @events.maximum('created_at').strftime('%Y-%m-%d')
|
end_date = @events.maximum('created_at').strftime('%Y-%m-%d')
|
||||||
if start_date != nil && end_date != nil
|
unless start_date == nil || end_date == nil
|
||||||
@events_time = var_time(start_date, end_date, @events, 'created_at')
|
@events_time = var_time(start_date, end_date, @events, 'created_at')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -79,8 +87,13 @@ module Admin
|
||||||
typelength += myevent.event_type.length
|
typelength += myevent.event_type.length
|
||||||
@totallength += myevent.event_type.length
|
@totallength += myevent.event_type.length
|
||||||
end
|
end
|
||||||
@eventstats[mytype.title] = { 'count' => events_mytype.count, 'length' => events_mytype.count * mytype.length } if @eventstats[mytype.title] == nil
|
if @eventstats[mytype.title] == nil
|
||||||
tmp = { "#{mystate.name}" => { 'type_state_count' => events_mytype_mystate.count, 'type_state_length' => typelength } }
|
@eventstats[mytype.title] = { 'count' => events_mytype.count,
|
||||||
|
'length' => events_mytype.count * mytype.length }
|
||||||
|
end
|
||||||
|
|
||||||
|
tmp = { "#{mystate.name}" => { 'type_state_count' => events_mytype_mystate.count,
|
||||||
|
'type_state_length' => typelength } }
|
||||||
@eventstats[mytype.title].merge!(tmp)
|
@eventstats[mytype.title].merge!(tmp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -88,7 +101,8 @@ module Admin
|
||||||
@eventstats['totallength'] = @totallength
|
@eventstats['totallength'] = @totallength
|
||||||
|
|
||||||
# SPEAKERS stats
|
# SPEAKERS stats
|
||||||
@speakers = User.joins(:events).where('events.conference_id = ? AND events.state LIKE ?', @conference.id, 'confirmed').uniq
|
@speakers = User.joins(:events).where('events.conference_id = ? AND events.state LIKE ?',
|
||||||
|
@conference.id, 'confirmed').uniq
|
||||||
@speaker_fields_user = %w(name email affiliation)
|
@speaker_fields_user = %w(name email affiliation)
|
||||||
@speaker_fields_reg = %w(arrival departure)
|
@speaker_fields_reg = %w(arrival departure)
|
||||||
# TICKETS stats
|
# TICKETS stats
|
||||||
|
|
@ -98,7 +112,7 @@ module Admin
|
||||||
|
|
||||||
@tickets_time = []
|
@tickets_time = []
|
||||||
|
|
||||||
if @conference.registration_start_date and @conference.end_date and @registered > 0 and @supporter_levels
|
if @conference.registration_start_date && @conference.end_date && @registered > 0 && @supporter_levels
|
||||||
start_date = @conference.registration_start_date
|
start_date = @conference.registration_start_date
|
||||||
end_date = @conference.end_date
|
end_date = @conference.end_date
|
||||||
levels = []
|
levels = []
|
||||||
|
|
@ -108,10 +122,13 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
(start_date..end_date).each do |day|
|
(start_date..end_date).each do |day|
|
||||||
if @tickets.where('supporter_registrations.created_at LIKE ?', "%#{day}%").where('supporter_levels.title' => levels).count != 0
|
if @tickets.where('supporter_registrations.created_at LIKE ?', "%#{day}%").where(
|
||||||
|
'supporter_levels.title' => levels).count != 0
|
||||||
@conference.supporter_levels.each do |level|
|
@conference.supporter_levels.each do |level|
|
||||||
|
|
||||||
day_ticket_count = @tickets.where('supporter_registrations.created_at LIKE ? AND supporter_levels.title LIKE ?', "%#{day}%", "%#{level.title}%").count
|
day_ticket_count = @tickets.where('supporter_registrations.created_at LIKE ?
|
||||||
|
AND supporter_levels.title LIKE ?',
|
||||||
|
"%#{day}%", "%#{level.title}%").count
|
||||||
|
|
||||||
index = @tickets_time.index { |v| v['key'] == "#{level.title}" }
|
index = @tickets_time.index { |v| v['key'] == "#{level.title}" }
|
||||||
@tickets_time[index]['values'] << { 'label' => "#{day}", 'value' => day_ticket_count }
|
@tickets_time[index]['values'] << { 'label' => "#{day}", 'value' => day_ticket_count }
|
||||||
|
|
@ -123,7 +140,8 @@ module Admin
|
||||||
@tickets_time.each do |ticket|
|
@tickets_time.each do |ticket|
|
||||||
value = ticket['values'].map { |x| x['value'] }.sum
|
value = ticket['values'].map { |x| x['value'] }.sum
|
||||||
percent = (value.to_f / @tickets.count * 100).round(2)
|
percent = (value.to_f / @tickets.count * 100).round(2)
|
||||||
@tickets_distribution << { 'status' => ticket['key'], 'value' => value, 'percent' => percent }
|
@tickets_distribution << { 'status' => ticket['key'],
|
||||||
|
'value' => value, 'percent' => percent }
|
||||||
end
|
end
|
||||||
|
|
||||||
# OTHER_INFO chart / To be 'Questions'
|
# OTHER_INFO chart / To be 'Questions'
|
||||||
|
|
@ -136,7 +154,7 @@ module Admin
|
||||||
]
|
]
|
||||||
|
|
||||||
# REGISTRATIONS, registered_time
|
# REGISTRATIONS, registered_time
|
||||||
if @conference.registration_start_date and @conference.end_date and @registered > 0
|
if @conference.registration_start_date && @conference.end_date && @registered > 0
|
||||||
start_date = @conference.registration_start_date
|
start_date = @conference.registration_start_date
|
||||||
end_date = @conference.end_date
|
end_date = @conference.end_date
|
||||||
@registered_time = var_time(start_date, end_date, @registrations, 'created_at')
|
@registered_time = var_time(start_date, end_date, @registrations, 'created_at')
|
||||||
|
|
@ -156,39 +174,39 @@ module Admin
|
||||||
result << { 'status' => "#{day}", 'value' => day_var_count }
|
result << { 'status' => "#{day}", 'value' => day_var_count }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def var_state_func(vars, field, mystate)
|
def var_state_func(vars, field, mystate)
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
for myvar in vars do
|
vars.each do |myvar|
|
||||||
# Find events per track and state
|
# Find events per track and state
|
||||||
value = @conference.events.where("#{field}_id" => myvar.id).where(state: mystate).count
|
value = @conference.events.where("#{field}_id" => myvar.id).where(state: mystate).count
|
||||||
# Find all events in that state
|
# Find all events in that state
|
||||||
total = @conference.events.where(state: mystate).count
|
total = @conference.events.where(state: mystate).count
|
||||||
status = "#{myvar.name}"
|
status = "#{myvar.name}"
|
||||||
|
|
||||||
|
percent = 0
|
||||||
if value != 0
|
if value != 0
|
||||||
percent = (value.to_f / total * 100).round(2)
|
percent = (value.to_f / total * 100).round(2)
|
||||||
result << { 'status' => status, 'value' => value, 'percent' => percent }
|
result << { 'status' => status, 'value' => value, 'percent' => percent }
|
||||||
else
|
|
||||||
percent = 0
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Get no of events for which the field is not set (Needed so that the pie shows half piece for 50%)
|
# Get no of events for which the field is not set (So that pie shows half piece for 50%)
|
||||||
sum = result.inject(0) { |sum, hash| sum + hash['value'] }
|
sum = result.inject(0) { |s, hash| s + hash['value'] }
|
||||||
value = total - sum if total and sum
|
value = total - sum
|
||||||
if sum != 0 && value != 0
|
if sum != 0 && value != 0
|
||||||
percent = (value.to_f / total * 100).round(2)
|
percent = (value.to_f / total * 100).round(2)
|
||||||
result << { 'status' => "no #{field} set", 'value' => value, 'percent' => percent }
|
result << { 'status' => "no #{field} set", 'value' => value, 'percent' => percent }
|
||||||
end
|
end
|
||||||
|
|
||||||
return result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def speaker_reg(speaker)
|
def speaker_reg(speaker)
|
||||||
speaker.registrations.where('conference_id = ? AND user_id = ?', @conference.id, speaker.id).first
|
speaker.registrations.where('conference_id = ? AND user_id = ?',
|
||||||
|
@conference.id, speaker.id).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def speaker_diet(reg)
|
def speaker_diet(reg)
|
||||||
|
|
@ -200,7 +218,8 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def social_event_count(event)
|
def social_event_count(event)
|
||||||
@conference.registrations.joins(:social_events).where('registrations_social_events.social_event_id = ?', event).count
|
@conference.registrations.joins(:social_events).where(
|
||||||
|
'registrations_social_events.social_event_id = ?', event).count
|
||||||
end
|
end
|
||||||
|
|
||||||
helper_method :speaker_reg
|
helper_method :speaker_reg
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
class Api::V1::EventsController < Api::BaseController
|
module Api
|
||||||
respond_to :json
|
module V1
|
||||||
|
class EventsController < Api::BaseController
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
events = Event.includes(:conference, :track, :room, :event_type, {:event_user => :user})
|
events = Event.includes(:conference, :track, :room, :event_type, event_user: :user)
|
||||||
unless params[:conference_id].blank?
|
unless params[:conference_id].blank?
|
||||||
events = events.where("conferences.guid" => params[:conference_id])
|
events = events.where('conferences.guid' => params[:conference_id])
|
||||||
|
end
|
||||||
|
respond_with events.confirmed
|
||||||
|
end
|
||||||
end
|
end
|
||||||
respond_with events.confirmed
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,18 @@
|
||||||
class Api::V1::SpeakersController < Api::BaseController
|
module Api
|
||||||
respond_to :json
|
module V1
|
||||||
|
class SpeakersController < Api::BaseController
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if params[:conference_id].blank?
|
if params[:conference_id].blank?
|
||||||
people = User.joins(:event_users)
|
users = User.joins(:event_users)
|
||||||
else
|
else
|
||||||
people = User.joins(:event_users => {:event => :conference})
|
users = User.joins(event_users: { event: :conference })
|
||||||
people = people.where("conferences.guid" => params[:conference_id])
|
users = users.where('conferences.guid' => params[:conference_id])
|
||||||
|
end
|
||||||
|
users = users.where('event_users.event_role' => 'speaker')
|
||||||
|
render json: users, each_serializer: SpeakerSerializer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
people = people.where("event_users.event_role" => "speaker")
|
|
||||||
render :json => users, :each_serializer => SpeakerSerializer
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,34 +4,40 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
def register
|
def register
|
||||||
# TODO Figure out how to change the route's id from :id to :conference_id
|
# TODO Figure out how to change the route's id from :id to :conference_id
|
||||||
@conference = Conference.find_by(short_title: params[:id])
|
@conference = Conference.find_by(short_title: params[:id])
|
||||||
@workshops = @conference.events.where("require_registration = ? AND state LIKE ?", true, 'confirmed')
|
@workshops = @conference.events.where('require_registration = ? AND state LIKE ?',
|
||||||
|
true, 'confirmed')
|
||||||
@user = current_user
|
@user = current_user
|
||||||
|
|
||||||
@registration = @user.registrations.where(:conference_id => @conference.id).first
|
@registration = @user.registrations.where(conference_id: @conference.id).first
|
||||||
@registered = true
|
@registered = true
|
||||||
if @registration.nil?
|
if @registration.nil?
|
||||||
@registered = false
|
@registered = false
|
||||||
@registration = @user.registrations.new(:conference_id => @conference.id)
|
@registration = @user.registrations.new(conference_id: @conference.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check if there's an existing SupporterRegistration for this email and link it when appropriate
|
# Check if there's an existing SupporterRegistration for this email and link it when appropriate
|
||||||
@registration.supporter_registration ||= @conference.supporter_registrations.where(:email => @user.email).first
|
@registration.supporter_registration ||= @conference.supporter_registrations.where(
|
||||||
@registration.supporter_registration ||= SupporterRegistration.new(:conference_id => @conference.id)
|
email: @user.email).first
|
||||||
|
@registration.supporter_registration ||= SupporterRegistration.new(conference_id: @conference.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO this is ugly
|
# TODO this is ugly
|
||||||
def update
|
def update
|
||||||
conference = Conference.find_by(short_title: params[:id])
|
conference = Conference.find_by(short_title: params[:id])
|
||||||
user = current_user
|
user = current_user
|
||||||
registration = user.registrations.where(:conference_id => conference.id).first
|
registration = user.registrations.where(conference_id: conference.id).first
|
||||||
update_registration = true
|
update_registration = true
|
||||||
# First verify that the supporter code is legit
|
# First verify that the supporter code is legit
|
||||||
if !params[:registration][:supporter_registration_attributes].nil? && !params[:registration][:supporter_registration_attributes][:code].empty?
|
if !params[:registration][:supporter_registration_attributes].nil? &&
|
||||||
regs = conference.supporter_registrations.where(:code => params[:registration][:supporter_registration_attributes][:code])
|
!params[:registration][:supporter_registration_attributes][:code].empty?
|
||||||
|
regs = conference.supporter_registrations.where(
|
||||||
|
code: params[:registration][:supporter_registration_attributes][:code])
|
||||||
|
|
||||||
if regs.count != 0
|
if regs.count != 0
|
||||||
if regs.where(:email => user.email).count == 0
|
if regs.where(email: user.email).count == 0
|
||||||
redirect_to(register_conference_path(:id => conference.short_title), :alert => "This code is already in use. Please contact #{conference.contact_email} for assistance.")
|
redirect_to(register_conference_path(id: conference.short_title),
|
||||||
|
alert: "This code is already in use.
|
||||||
|
Please contact #{conference.contact_email} for assistance.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -46,10 +52,10 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
registration = user.registrations.new(registration_params)
|
registration = user.registrations.new(registration_params)
|
||||||
if conference.use_supporter_levels? && !supporter_reg.nil?
|
if conference.use_supporter_levels? && !supporter_reg.nil?
|
||||||
if !supporter_reg[:id].blank?
|
if !supporter_reg[:id].blank?
|
||||||
# This means that their supporter registration was entered ahead of time, probably by an admin
|
# Means that their supporter registration was entered ahead of time, by an admin
|
||||||
registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id])
|
registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id])
|
||||||
if registration.supporter_registration.email != user.email
|
if registration.supporter_registration.email != user.email
|
||||||
raise "Invalid code"
|
raise 'Invalid code'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
registration.supporter_registration = conference.
|
registration.supporter_registration = conference.
|
||||||
|
|
@ -63,14 +69,15 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
registration.update_attributes!(registration_params)
|
registration.update_attributes!(registration_params)
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
Rails.logger.debug e.backtrace.join("\n")
|
Rails.logger.debug e.backtrace.join('\n')
|
||||||
redirect_to(register_conference_path(:id => conference.short_title), :alert => 'Registration failed:' + e.message)
|
redirect_to(register_conference_path(id: conference.short_title),
|
||||||
|
alert: 'Registration failed:' + e.message)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_message = "You are now registered."
|
redirect_message = 'You are now registered.'
|
||||||
if update_registration
|
if update_registration
|
||||||
redirect_message = "Registration updated."
|
redirect_message = 'Registration updated.'
|
||||||
else
|
else
|
||||||
# Track ahoy event
|
# Track ahoy event
|
||||||
ahoy.track 'Registered', title: 'New registration'
|
ahoy.track 'Registered', title: 'New registration'
|
||||||
|
|
@ -78,13 +85,14 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
Mailbot.registration_mail(conference, current_user).deliver
|
Mailbot.registration_mail(conference, current_user).deliver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to(register_conference_path(:id => conference.short_title), :notice => redirect_message)
|
redirect_to(register_conference_path(id: conference.short_title),
|
||||||
|
notice: redirect_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unregister
|
def unregister
|
||||||
conference = Conference.find_by(short_title: params[:id])
|
conference = Conference.find_by(short_title: params[:id])
|
||||||
user = current_user
|
user = current_user
|
||||||
registration = user.registrations.where(:conference_id => conference.id).first
|
registration = user.registrations.where(conference_id: conference.id).first
|
||||||
registration.destroy
|
registration.destroy
|
||||||
redirect_to :root
|
redirect_to :root
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@openids = Openid.where(user_id: current_user.id).order(:provider)
|
||||||
@user = User.find(current_user.id)
|
@user = User.find(current_user.id)
|
||||||
email_changed = false
|
email_changed = false
|
||||||
|
|
||||||
|
|
@ -20,14 +21,14 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
password_changed = false
|
password_changed = false
|
||||||
if !params[:user][:password].nil?
|
if !params[:user][:password].nil?
|
||||||
if !params[:user][:password].empty?
|
if !params[:user][:password].empty?
|
||||||
password_changed = true
|
password_changed = true
|
||||||
else
|
else
|
||||||
params[:user].delete :password
|
params[:user].delete :password
|
||||||
params[:user].delete :password_confirmation
|
params[:user].delete :password_confirmation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if email_changed or password_changed
|
if email_changed || password_changed
|
||||||
successfully_updated = @user.update_with_password(account_update_params)
|
successfully_updated = @user.update_with_password(account_update_params)
|
||||||
else
|
else
|
||||||
params[:user].delete :current_password
|
params[:user].delete :current_password
|
||||||
|
|
@ -36,7 +37,7 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
|
|
||||||
if successfully_updated
|
if successfully_updated
|
||||||
if email_changed
|
if email_changed
|
||||||
if !@user.nil?
|
unless @user.nil?
|
||||||
@user.update_attribute('email', params[:user][:email])
|
@user.update_attribute('email', params[:user][:email])
|
||||||
end
|
end
|
||||||
set_flash_message :notice, :update_needs_confirmation
|
set_flash_message :notice, :update_needs_confirmation
|
||||||
|
|
@ -66,7 +67,8 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
def configure_permitted_parameters
|
def configure_permitted_parameters
|
||||||
devise_parameter_sanitizer.for(:account_update) do |u|
|
devise_parameter_sanitizer.for(:account_update) do |u|
|
||||||
u.
|
u.
|
||||||
permit(:email, :password, :password_confirmation, :current_password, :name, :biography)
|
permit(:email, :password, :password_confirmation, :current_password, :name, :biography,
|
||||||
|
:nickname, :affiliation)
|
||||||
end
|
end
|
||||||
devise_parameter_sanitizer.for(:sign_up) do |u|
|
devise_parameter_sanitizer.for(:sign_up) do |u|
|
||||||
u.
|
u.
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ class Conference < ActiveRecord::Base
|
||||||
def user_registered? user
|
def user_registered? user
|
||||||
return nil if user.nil?
|
return nil if user.nil?
|
||||||
|
|
||||||
if self.registrations.where(user_id: user.id).count == 0
|
if registrations.where(user_id: user.id).count == 0
|
||||||
logger.debug("User #{user.email} isn't registered to self.title")
|
logger.debug("User #{user.email} isn't registered to self.title")
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class DatatableSupporters < Datatable
|
||||||
items.each do |i|
|
items.each do |i|
|
||||||
item = []
|
item = []
|
||||||
if i.name.blank?
|
if i.name.blank?
|
||||||
if !i.registration.nil? && !i.registration.user.nil?
|
unless i.registration.nil? || i.registration.user.nil?
|
||||||
item << i.registration.user.name
|
item << i.registration.user.name
|
||||||
else
|
else
|
||||||
item << "Unknown"
|
item << "Unknown"
|
||||||
|
|
@ -15,7 +15,7 @@ class DatatableSupporters < Datatable
|
||||||
end
|
end
|
||||||
|
|
||||||
if i.email.blank?
|
if i.email.blank?
|
||||||
if !i.registration.nil? && !i.registration.user.nil?
|
unless i.registration.nil? && i.registration.user.nil?
|
||||||
item << i.registration.user.email
|
item << i.registration.user.email
|
||||||
else
|
else
|
||||||
item << "Unknown"
|
item << "Unknown"
|
||||||
|
|
|
||||||
|
|
@ -7,46 +7,48 @@ class EmailSettings < ActiveRecord::Base
|
||||||
|
|
||||||
def get_values(conference, user, event = nil)
|
def get_values(conference, user, event = nil)
|
||||||
h = {
|
h = {
|
||||||
'email' => user.email,
|
'email' => user.email,
|
||||||
'name' => user.name,
|
'name' => user.name,
|
||||||
'conference' => conference.title,
|
'conference' => conference.title,
|
||||||
'registrationlink' => Rails.application.routes.url_helpers.register_conference_url(conference.short_title, host: CONFIG['url_for_emails'])
|
'registrationlink' => Rails.application.routes.url_helpers.register_conference_url(
|
||||||
|
conference.short_title, host: CONFIG['url_for_emails'])
|
||||||
}
|
}
|
||||||
|
|
||||||
if !event.nil?
|
if !event.nil?
|
||||||
h['eventtitle'] = event.title
|
h['eventtitle'] = event.title
|
||||||
h['proposalslink'] = Rails.application.routes.url_helpers.conference_proposal_url(conference.short_title, event, host: CONFIG['url_for_emails'])
|
h['proposalslink'] = Rails.application.routes.url_helpers.conference_proposal_url(
|
||||||
|
conference.short_title, event, host: CONFIG['url_for_emails'])
|
||||||
end
|
end
|
||||||
h
|
h
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_registration_email(conference, user)
|
def generate_registration_email(conference, user)
|
||||||
values = get_values(conference, user)
|
values = get_values(conference, user)
|
||||||
template = self.registration_email_template
|
template = registration_email_template
|
||||||
parse_template(template, values)
|
parse_template(template, values)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_accepted_email(event)
|
def generate_accepted_email(event)
|
||||||
values = get_values(event.conference, event.submitter, event)
|
values = get_values(event.conference, event.submitter, event)
|
||||||
template = self.accepted_email_template
|
template = accepted_email_template
|
||||||
parse_template(template, values)
|
parse_template(template, values)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_rejected_email(event)
|
def generate_rejected_email(event)
|
||||||
values = get_values(event.conference, event.submitter, event)
|
values = get_values(event.conference, event.submitter, event)
|
||||||
template = self.rejected_email_template
|
template = rejected_email_template
|
||||||
parse_template(template, values)
|
parse_template(template, values)
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirmed_but_not_registered_email(event)
|
def confirmed_but_not_registered_email(event)
|
||||||
values = get_values(event.conference, event.submitter, event)
|
values = get_values(event.conference, event.submitter, event)
|
||||||
template = self.confirmed_email_template
|
template = confirmed_email_template
|
||||||
parse_template(template, values)
|
parse_template(template, values)
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_template(text, values)
|
def parse_template(text, values)
|
||||||
values.each do |key, value|
|
values.each do |key, value|
|
||||||
text = text.gsub"{#{key}}", value unless text.blank?
|
text = text.gsub "{#{key}}", value unless text.blank?
|
||||||
end
|
end
|
||||||
text
|
text
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -71,23 +71,23 @@ class Event < ActiveRecord::Base
|
||||||
|
|
||||||
def average_rating
|
def average_rating
|
||||||
@total_rating = 0
|
@total_rating = 0
|
||||||
self.votes.each do |vote|
|
votes.each do |vote|
|
||||||
@total_rating = @total_rating + vote.rating
|
@total_rating = @total_rating + vote.rating
|
||||||
end
|
end
|
||||||
@total = self.votes.size
|
@total = votes.size
|
||||||
number_with_precision(@total_rating / @total.to_f, precision: 2, strip_insignificant_zeros: true)
|
number_with_precision(@total_rating / @total.to_f, precision: 2, strip_insignificant_zeros: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def submitter
|
def submitter
|
||||||
result = self.event_users.where(event_role: 'submitter').first
|
result = event_users.where(event_role: 'submitter').first
|
||||||
if !result.nil?
|
if !result.nil?
|
||||||
result.user
|
result.user
|
||||||
else
|
else
|
||||||
user = nil
|
user = nil
|
||||||
# Perhaps the event_users haven't been saved, if this is a new proposal
|
# Perhaps the event_users haven't been saved, if this is a new proposal
|
||||||
self.event_users.each do |p|
|
event_users.each do |u|
|
||||||
if p.event_role == 'submitter'
|
if u.event_role == 'submitter'
|
||||||
user = p.user
|
user = u.user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
user
|
user
|
||||||
|
|
@ -97,34 +97,34 @@ class Event < ActiveRecord::Base
|
||||||
def as_json(options)
|
def as_json(options)
|
||||||
json = super(options)
|
json = super(options)
|
||||||
|
|
||||||
if self.room.nil?
|
if room.nil?
|
||||||
json[:room_guid] = nil
|
json[:room_guid] = nil
|
||||||
else
|
else
|
||||||
json[:room_guid] = self.room.guid
|
json[:room_guid] = room.guid
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.track.nil?
|
if track.nil?
|
||||||
json[:track_color] = '#ffffff'
|
json[:track_color] = '#ffffff'
|
||||||
else
|
else
|
||||||
json[:track_color] = self.track.color;
|
json[:track_color] = track.color
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.event_type.nil?
|
if event_type.nil?
|
||||||
json[:length] = 25
|
json[:length] = 25
|
||||||
else
|
else
|
||||||
json[:length] = self.event_type.length
|
json[:length] = event_type.length
|
||||||
end
|
end
|
||||||
|
|
||||||
json
|
json
|
||||||
end
|
end
|
||||||
|
|
||||||
def transition_possible?(transition)
|
def transition_possible?(transition)
|
||||||
self.class.state_machine.events_for(self.current_state).include?(transition)
|
self.class.state_machine.events_for(current_state).include?(transition)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_confirmation
|
def process_confirmation
|
||||||
if self.conference.email_settings.send_on_confirmed_without_registration?
|
if conference.email_settings.send_on_confirmed_without_registration?
|
||||||
if self.conference.registrations.where(:user_id => self.submitter.id).first.nil?
|
if conference.registrations.where(user_id: submitter.id).first.nil?
|
||||||
Mailbot.confirm_reminder_mail(self).deliver
|
Mailbot.confirm_reminder_mail(self).deliver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -147,10 +147,10 @@ class Event < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def abstract_word_count
|
def abstract_word_count
|
||||||
if self.abstract.nil?
|
if abstract.nil?
|
||||||
0
|
0
|
||||||
else
|
else
|
||||||
self.abstract.split.size
|
abstract.split.size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -181,23 +181,19 @@ class Event < ActiveRecord::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def abstract_limit
|
def abstract_limit
|
||||||
len = self.abstract.split.size
|
len = abstract.split.size
|
||||||
max = self.event_type.maximum_abstract_length
|
max = event_type.maximum_abstract_length
|
||||||
min = self.event_type.minimum_abstract_length
|
min = event_type.minimum_abstract_length
|
||||||
|
|
||||||
if len < min
|
if len < min
|
||||||
errors.add(:abstract, "cannot have less than #{min} words")
|
errors.add(:abstract, "cannot have less than #{min} words")
|
||||||
end
|
end
|
||||||
|
|
||||||
if len > max
|
errors.add(:abstract, "cannot have more than #{max} words") if len > max
|
||||||
errors.add(:abstract, "cannot have more than #{max} words")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def biography_exists
|
def biography_exists
|
||||||
if self.submitter.biography_word_count == 0
|
errors.add(:user_biography, 'must be filled out') if submitter.biography_word_count == 0
|
||||||
errors.add(:user_biography, 'must be filled out')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_guid
|
def generate_guid
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ class User < ActiveRecord::Base
|
||||||
include Gravtastic
|
include Gravtastic
|
||||||
gravtastic size: 32
|
gravtastic size: 32
|
||||||
|
|
||||||
|
|
||||||
# Include default devise modules. Others available are:
|
# Include default devise modules. Others available are:
|
||||||
# :token_authenticatable, :confirmable,
|
# :token_authenticatable, :confirmable,
|
||||||
# :lockable, :timeoutable and :omniauthable
|
# :lockable, :timeoutable and :omniauthable
|
||||||
|
|
@ -54,7 +53,7 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_roles
|
def get_roles
|
||||||
return self.roles
|
roles
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_role
|
def setup_role
|
||||||
|
|
@ -86,7 +85,7 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def attended
|
def attended
|
||||||
registrations_attended = self.registrations.where(attended: true)
|
registrations_attended = registrations.where(attended: true)
|
||||||
if registrations_attended.count == 0
|
if registrations_attended.count == 0
|
||||||
'None'
|
'None'
|
||||||
else
|
else
|
||||||
|
|
@ -98,32 +97,31 @@ class User < ActiveRecord::Base
|
||||||
!confirmed_at.nil?
|
!confirmed_at.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def attending_conference? conference
|
def attending_conference?(conference)
|
||||||
Registration.where(conference_id: conference.id,
|
Registration.where(conference_id: conference.id,
|
||||||
user_id: self.id).count
|
user_id: id).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def proposals conference
|
def proposals(conference)
|
||||||
events.where('conference_id = ? AND event_users.event_role=?', conference.id, 'submitter')
|
events.where('conference_id = ? AND event_users.event_role=?', conference.id, 'submitter')
|
||||||
end
|
end
|
||||||
|
|
||||||
def proposal_count conference
|
def proposal_count(conference)
|
||||||
proposals(conference).count
|
proposals(conference).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def biography_word_count
|
def biography_word_count
|
||||||
if self.biography.nil?
|
if biography.nil?
|
||||||
0
|
0
|
||||||
else
|
else
|
||||||
self.biography.split.size
|
biography.split.size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def biography_limit
|
def biography_limit
|
||||||
if !self.biography.nil? && self.biography.split.size > 150
|
errors.add(:abstract, 'cannot have more than 150 words') if !biography.nil? &&
|
||||||
errors.add(:abstract, 'cannot have more than 150 words')
|
biography.split.size > 150
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ class EventSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
def date
|
def date
|
||||||
t = object.start_time
|
t = object.start_time
|
||||||
t.blank? ? '' : %(#{t.time.strftime('%Y-%m-%dT%H:%M:%S')}#{t.formatted_offset(false)})
|
t.blank? ? '' : %{ #{t.time.strftime('%Y-%m-%dT%H:%M:%S')}#{t.formatted_offset(false)} }
|
||||||
end
|
end
|
||||||
|
|
||||||
def speaker_ids
|
def speaker_ids
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= semantic_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f|
|
= semantic_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
|
||||||
= f.inputs :name => "Profile" do
|
= f.inputs name: 'Profile' do
|
||||||
= f.fields_for :user do |u|
|
= f.input :name, as: :string
|
||||||
= u.input :name, :as => :string
|
= f.input :nickname, as: :string
|
||||||
= u.input :nickname, :as => :string
|
= f.input :affiliation, as: :string,
|
||||||
= u.input :affiliation, :as => :string, :hint => "This could be a company, a user group, or nothing at all."
|
hint: 'This could be a company, a user group, or nothing at all.'
|
||||||
= u.input :biography, :input_html => {:rows => 5, "onkeyup" => "word_count(this, 'biography-count', 150)"}
|
= f.input :biography, input_html: {rows: 5,
|
||||||
You have used
|
'onkeyup' => "word_count(this, 'biography-count', 150)"}
|
||||||
%span#biography-count #{current_user.biography_word_count}
|
You have used
|
||||||
words. Biographies are limited to 150 words.
|
%span#biography-count #{current_user.biography_word_count}
|
||||||
%br
|
words. Biographies are limited to 150 words.
|
||||||
%br
|
%br
|
||||||
= render :partial => 'devise/registrations/volunteeruser', :locals => {:u => u}
|
%br
|
||||||
= f.inputs :name => 'OpenID' do
|
= f.inputs name: 'OpenID' do
|
||||||
%h4
|
%h4
|
||||||
Currently using the following openIDs:
|
Currently using the following openIDs:
|
||||||
- @openids.each do |openid|
|
- @openids.each do |openid|
|
||||||
|
|
@ -25,9 +25,10 @@
|
||||||
openID while logged in to OSEM
|
openID while logged in to OSEM
|
||||||
= render 'devise/shared/openid'
|
= render 'devise/shared/openid'
|
||||||
|
|
||||||
= f.inputs :name => "Account" do
|
= f.inputs name: 'Account' do
|
||||||
= f.input :email, :required => false
|
= f.input :email, :required => false, :input_html => {autocomplete: "off"}
|
||||||
= f.input :password, :hint => "(Leave blank if you don't want to change it)", :input_html => {:autocomplete => "off"}
|
= f.input :password, hint: "(Leave blank if you don't want to change it)", input_html: {autocomplete: 'off'}
|
||||||
= f.input :password_confirmation, :input_html => {:autocomplete => "off"}
|
= f.input :password_confirmation, input_html: {autocomplete: 'off'}
|
||||||
= f.input :current_password, :input_html => {:autocomplete => "off"}, :hint => "(we need your current password to confirm password or email changes)"
|
= f.input :current_password, input_html: {autocomplete: 'off'},
|
||||||
= f.action :submit, :as => :button, :label => "Update", :button_html => {:class => "btn btn-primary"}
|
hint: '(we need your current password to confirm password or email changes)'
|
||||||
|
= f.action :submit, as: :button, label: 'Update', button_html: {class: 'btn btn-primary'}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue