#{params[:location]}
"
if params[:location] == params[:url]
report += " on line #{params[:lineNumber]}
"
else
report += " in #{params[:url]}:#{params[:lineNumber]}
"
end
begin
# log the error
logger.info exception.to_s
logger.info exception.backtrace.join("\n")
UserMailer.send_mail(:error_report) do
[
"A JavaScript error has occurred",
report,
params[:message],
nil,
request,
params,
current_user,
Time.now.strftime("%d/%m/%Y %H:%M")
]
end if Rails.env.preview? || Rails.env.production?
rescue exception2
logger.info exception2.to_s
logger.info exception2.backtrace.join("\n")
end
render json: {}
end
rescue_from ActiveRecord::RecordNotFound do |exception|
do_404
end
rescue_from ActiveRecord::PremissionDenied do |exception|
do_403
end
rescue_from AbstractController::ActionNotFound do |exception|
@banner_image = 'grafitti.jpg'
if current_user
@page_title = nil#'page_titles.Please_Login'
do_403 'not_a_translator'
#return
else
@page_title = 'page_titles.403.Please_Login'
do_403 'translator_login'
end
end
def locale_not_enabled!(locale = nil)
locale_not_available!(locale)
end
def locale_not_available!(locale = nil)
set_default_locale
params[:_original_action] = params[:action]
params[:action] = 'error-locale-not-available'
@page_title = 'page_titles.404.Locale_Not_Available'
@main_title_vars = { vars: { language: view_context.language_name(locale) } }
@main_title = 'error.locale_not_available.title'
render 'application/locale_not_available', status: 404
end
rescue_from StandardError do |exception|
# log the error
logger.info exception.to_s
logger.info exception.backtrace.join("\n")
# send and email if this is production
suppress(Exception) do
UserMailer.send_mail(:error_report) do
[
"An error has occurred in #{Rails.env}",
nil,
exception.to_s,
exception.backtrace.join("\n"),
request,
params,
current_user,
Time.now.strftime("%d/%m/%Y %H:%M")
]
end if Rails.env.preview? || Rails.env.production?
end
# raise the error if we are in development so that we can debug it
raise exception if Rails.env.development?
# show the error page
error_500 exception
end
def generate_confirmation(user, url, expiry = nil)
if user.is_a? String
user = User.find_by_email(user)
# if the user doesn't exist, just show them a 403
do_403 unless user.present?
end
expiry ||= (Time.now + 12.hours)
session[:confirm_uid] = user.id
unless user.locale.present?
user.locale = I18n.locale
user.save
end
# send the confirmation email and make sure it get sent as quickly as possible
UserMailer.send_mail :email_confirmation do
EmailConfirmation.create(user_id: user.id, expiry: expiry, url: url)
end
end
def user_settings
@conferences = Array.new
if logged_in?
Conference.all.each do | conference |
@conferences << conference if conference.host? current_user
end
end
@main_title = @page_title = 'page_titles.user_settings.Your_Account'
end
def contact
@main_title = @page_title = 'page_titles.contact.Contact_Us'
end
def contact_send
email_list = ['Godwin A translation for #{key}
in #{locale.to_s}
was found. The text that was rendered to the user was:
#{str || 'nil'}", exception.to_s, nil, request, params, current_user, Time.now.strftime("%d/%m/%Y %H:%M") ] end if Rails.env.preview? || Rails.env.production? rescue exception2 logger.info exception2.to_s logger.info exception2.backtrace.join("\n") end end def get_block_data conference = @this_conference || @conference @workshop_blocks = conference.workshop_blocks || [] @block_days = [] day = conference.start_date while day <= conference.end_date @block_days << day.wday day += 1.day end end def get_scheule_data(do_analyze = true) conference = @this_conference || @conference @meals = Hash[(conference.meals || {}).map{ |k, v| [k.to_i, v] }].sort.to_h @events = Event.where(:conference_id => conference.id).order(start_time: :asc) @workshops = Workshop.where(:conference_id => conference.id).order(start_time: :asc) @locations = {} get_block_data @schedule = {} day_1 = conference.start_date.wday @workshop_blocks.each_with_index do | info, block | info['days'].each do | block_day | day_diff = block_day.to_i - day_1 day_diff += 7 if day_diff < 0 day = (conference.start_date + day_diff.days).to_date time = info['time'].to_f @schedule[day] ||= { times: {}, locations: {} } @schedule[day][:times][time] ||= {} @schedule[day][:times][time][:type] = :workshop @schedule[day][:times][time][:length] = info['length'].to_f @schedule[day][:times][time][:item] = { block: block, workshops: {} } end end @workshops.each do | workshop | if workshop.block.present? block = @workshop_blocks[workshop.block['block'].to_i] day_diff = workshop.block['day'].to_i - day_1 day_diff += 7 if day_diff < 0 day = (conference.start_date + day_diff.days).to_date if @schedule[day].present? && @schedule[day][:times].present? && @schedule[day][:times][block['time'].to_f].present? @schedule[day][:times][block['time'].to_f][:item][:workshops][workshop.event_location_id] = { workshop: workshop, status: { errors: [], warnings: [], conflict_score: nil } } @schedule[day][:locations][workshop.event_location_id] ||= workshop.event_location if workshop.event_location.present? end end end @meals.each do | time, meal | day = meal['day'].to_date time = meal['time'].to_f @schedule[day] ||= {} @schedule[day][:times] ||= {} @schedule[day][:times][time] ||= {} @schedule[day][:times][time][:type] = :meal @schedule[day][:times][time][:length] = (meal['length'] || 1.0).to_f @schedule[day][:times][time][:item] = meal end @events.each do | event | day = event.start_time.midnight.to_date time = event.start_time.hour.to_f + (event.start_time.min / 60.0) @schedule[day] ||= {} @schedule[day][:times] ||= {} @schedule[day][:times][time] ||= {} @schedule[day][:times][time][:type] = :event @schedule[day][:times][time][:length] = (event.end_time - event.start_time) / 3600.0 @schedule[day][:times][time][:item] = event end @schedule = @schedule.sort.to_h @schedule.each do | day, data | @schedule[day][:times] = data[:times].sort.to_h end @schedule.each do | day, data | last_event = nil data[:times].each do | time, time_data | if last_event.present? @schedule[day][:times][last_event][:next_event] = time end last_event = time end end @schedule.deep_dup.each do | day, data | data[:times].each do | time, time_data | if time_data[:next_event].present? || time_data[:length] > 0.5 span = 0.5 length = time_data[:next_event].present? ? time_data[:next_event] - time : time_data[:length] while span < length @schedule[day][:times][time + span] ||= { type: (span >= time_data[:length] ? :empty : :nil), length: 0.5 } span += 0.5 end end end end @schedule = @schedule.sort.to_h return unless do_analyze @schedule.each do | day, data | @schedule[day][:times] = data[:times].sort.to_h @schedule[day][:locations][0] = :add if @schedule[day][:locations].size > 0 data[:times].each do | time, time_data | if time_data[:type] == :workshop && time_data[:item].present? && time_data[:item][:workshops].present? ids = time_data[:item][:workshops].keys (0..ids.length).each do | i | if time_data[:item][:workshops][ids[i]].present? workshop_i = time_data[:item][:workshops][ids[i]][:workshop] conflicts = {} (i+1..ids.length).each do | j | workshop_j = time_data[:item][:workshops][ids[j]].present? ? time_data[:item][:workshops][ids[j]][:workshop] : nil if workshop_i.present? && workshop_j.present? workshop_i.active_facilitators.each do | facilitator_i | workshop_j.active_facilitators.each do | facilitator_j | if facilitator_i.id == facilitator_j.id @schedule[day][:times][time][:status] ||= {} @schedule[day][:times][time][:item][:workshops][ids[j]][:status][:errors] << { name: :common_facilitator, facilitator: facilitator_i, workshop: workshop_i, i18nVars: { facilitator_name: facilitator_i.name, workshop_title: workshop_i.title } } end end end end end (0..ids.length).each do | j | workshop_j = time_data[:item][:workshops][ids[j]].present? ? time_data[:item][:workshops][ids[j]][:workshop] : nil if workshop_i.present? && workshop_j.present? && workshop_i.id != workshop_j.id workshop_i.interested.each do | interested_i | workshop_j.interested.each do | interested_j | conflicts[interested_i.id] ||= true end end end end location = workshop_i.event_location || EventLocation.new needs = JSON.parse(workshop_i.needs || '[]').map &:to_sym amenities = JSON.parse(location.amenities || '[]').map &:to_sym needs.each do | need | @schedule[day][:times][time][:item][:workshops][ids[i]][:status][:errors] << { name: :need_not_available, need: need, location: location, workshop: workshop_i, i18nVars: { need: need.to_s, location: location.title, workshop_title: workshop_i.title } } 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 end end end end end end end