Merge master

This commit is contained in:
Michael Ball 2020-02-06 01:20:11 -08:00
commit 7586112f72
217 changed files with 2853 additions and 3035 deletions

View file

@ -6,7 +6,7 @@ module Admin
load_and_authorize_resource through: :conference
def index
@file_name = "booths_for_#{@conference.short_title}"
@file_name = "#{(t 'booth').pluralize}_for_#{@conference.short_title}"
@booth_export_option = params[:booth_export_option]
respond_to do |format|
format.html
@ -14,12 +14,12 @@ module Admin
format.json { render json: Booth.where(state: :confirmed, program: @program).to_json }
format.xlsx do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\""
render 'booths'
render 'booths', layout: false
end
format.pdf { render 'booths' }
format.pdf { render 'booths', layout: false }
format.csv do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
render 'booths'
render 'booths', layout: false
end
end
end
@ -39,9 +39,9 @@ module Admin
if @booth.save
redirect_to admin_conference_booths_path,
notice: 'Booth successfully created.'
notice: "#{(t 'booth').capitalize} successfully created."
else
flash.now[:error] = "Creating booth failed. #{@booth.errors.full_messages.to_sentence}."
flash.now[:error] = "Creating #{t 'booth'} failed. #{@booth.errors.full_messages.to_sentence}."
render :new
end
end
@ -57,9 +57,9 @@ module Admin
if @booth.save
redirect_to admin_conference_booths_path,
notice: "Successfully updated booth for #{@booth.title}."
notice: "Successfully updated #{t 'booth'} for #{@booth.title}."
else
flash.now[:error] = "An error prohibited the Booth for #{@booth.title} "\
flash.now[:error] = "An error prohibited the #{t'booth'} for #{@booth.title} "\
"#{@booth.errors.full_messages.join('. ')}."
render :edit
end
@ -70,47 +70,49 @@ module Admin
if @booth.save
if @conference.email_settings.send_on_booths_acceptance
Mailbot.conference_booths_acceptance_mail(@booth).deliver
Mailbot.conference_booths_acceptance_mail(@booth).deliver_later
end
redirect_to admin_conference_booths_path(conference_id: @conference.short_title),
notice: 'Booth successfully accepted!'
notice: "#{(t'booth').capitalize} successfully accepted!"
else
redirect_to admin_conference_booths_path(conference_id: @conference.short_title)
flash[:error] = "Booth could not be accepted. #{@booth.errors.full_messages.to_sentence}."
flash[:error] = "#{(t 'booth').capitalize} could not be accepted. #{@booth.errors.full_messages.to_sentence}."
end
end
def to_accept
update_state(:to_accept, 'Booth to accept')
update_state(:to_accept, "#{(t'booth').capitalize} to accept")
end
def to_reject
update_state(:to_reject, 'Booth to reject')
update_state(:to_reject, "#{(t'booth').capitalize} to reject")
end
def reject
@booth.reject!
if @booth.save
Mailbot.conference_booths_rejection_mail(@booth).deliver
if @conference.email_settings.send_on_booths_rejection
Mailbot.conference_booths_rejection_mail(@booth).deliver_later
end
redirect_to admin_conference_booths_path(conference_id: @conference.short_title),
notice: 'Booth successfully rejected.'
notice: "#{(t'booth').capitalize} successfully rejected."
else
redirect_to admin_conference_booths_path(conference_id: @conference.short_title)
flash[:error] = "Booth could not be rejected. #{@booth.errors.full_messages.to_sentence}."
flash[:error] = "#{(t 'booth').capitalize} could not be rejected. #{@booth.errors.full_messages.to_sentence}."
end
end
def restart
update_state(:restart, 'Booth is submitted')
update_state(:restart, "#{(t 'booth').capitalize} is submitted")
end
def cancel
update_state(:cancel, 'Booth is canceled')
update_state(:cancel, "#{(t 'booth').capitalize} is canceled")
end
def confirm
update_state(:confirm, 'Booth successfully confirmed')
update_state(:confirm, "#{(t 'booth').capitalize} successfully confirmed")
end
private

View file

@ -45,9 +45,9 @@ module Admin
def render_commercial
result = Commercial.render_from_url(params[:url])
if result[:error]
render text: result[:error], status: 400
render plain: result[:error], status: 400
else
render text: result[:html]
render plain: result[:html]
end
end
@ -70,7 +70,7 @@ module Admin
flash[:error] = errors_text
end
redirect_to :back
redirect_back(fallback_location: root_path)
end
private

View file

@ -37,43 +37,33 @@ module Admin
@top_submitter = Conference.get_top_submitter
@submissions = {}
@cfp_weeks = [0]
@registrations = {}
@registration_weeks = [0]
@tickets = {}
@ticket_weeks = [0]
@registrations = []
@submissions = []
@tickets = []
@conferences.each do |c|
# Event submissions over time chart
@submissions[c.short_title] = c.get_submissions_per_week
@cfp_weeks.push(@submissions[c.short_title].length)
# Conference registrations over time chart
@registrations[c.short_title] = c.get_registrations_per_week
@registration_weeks.push(@registrations[c.short_title].length)
@registrations << {
name: c.short_title,
data: c.get_registrations_per_week
}
# Event submissions over time chart
@submissions << {
name: c.short_title,
data: c.get_submissions_per_week
}
# Tickets sold over time chart
@tickets[c.short_title] = c.get_tickets_sold_per_week
@ticket_weeks.push(@tickets[c.short_title].length)
@tickets << {
name: c.short_title,
data: c.get_tickets_sold_per_week
}
end
@cfp_weeks = @cfp_weeks.max
@submissions = normalize_array_length(@submissions, @cfp_weeks)
@cfp_weeks = @cfp_weeks > 0 ? (1..@cfp_weeks).to_a : 1
@registration_weeks = @registration_weeks.max
@registrations = normalize_array_length(@registrations, @registration_weeks)
@registration_weeks = @registration_weeks > 0 ? (1..@registration_weeks).to_a : 1
@ticket_weeks = @ticket_weeks.max
@tickets = normalize_array_length(@tickets, @ticket_weeks)
@ticket_weeks = @ticket_weeks > 0 ? (1..@ticket_weeks).to_a : 1
@event_distribution = Conference.event_distribution
@user_distribution = Conference.user_distribution
@event_distribution_colors = Event::COLORS.values
@user_distribution = User.distribution
@user_distribution_colors = User::DISTRIBUTION_COLORS.values
end
def new
@ -138,35 +128,9 @@ module Admin
@conference_progress = @conference.get_status
# Line charts
@registrations = {@conference.short_title => @conference.get_registrations_per_week}
@registration_weeks = [0]
@registration_weeks.push(@registrations[@conference.short_title].length)
@registration_weeks = @registration_weeks.max
@registrations = normalize_array_length(@registrations, @registration_weeks)
@registration_weeks = @registration_weeks > 0 ? (1..@registration_weeks).to_a : 1
@submissions = Conference.get_event_state_line_colors
@submissions_data = @conference.get_submissions_data
@cfp_weeks = 0
if @submissions_data['Weeks']
@cfp_weeks = @submissions_data['Weeks']
@submissions_data = @submissions_data.except('Weeks')
end
@tickets_data = @conference.get_tickets_data
@ticket_weeks = 0
if @tickets_data['Weeks']
@ticket_weeks = @tickets_data['Weeks']
@tickets_data = @tickets_data.except('Weeks')
end
# Set line color using a hash function
@tickets = []
@tickets_data.each_key do |title|
@tickets.append(short_title: title, color: "\##{Digest::MD5.hexdigest(title)[0..5]}")
end
@registrations = @conference.get_registrations_per_week
@submissions = @conference.get_submissions_data
@tickets = @conference.get_tickets_data
# Doughnut charts
@event_type_distribution = @conference.event_type_distribution

View file

@ -3,6 +3,7 @@
module Admin
class EventSchedulesController < Admin::BaseController
load_and_authorize_resource :event_schedule
skip_before_action :verify_authenticity_token
def create
if @event_schedule.save

View file

@ -16,6 +16,7 @@ module Admin
@event_types = @program.event_types
@tracks_distribution_confirmed = @conference.tracks_distribution(:confirmed)
@event_distribution = @conference.event_distribution
@event_distribution_colors = Event::COLORS.values
@scheduled_event_distribution = @conference.scheduled_event_distribution
@file_name = "events_for_#{@conference.short_title}"
@event_export_option = params[:event_export_option]
@ -27,12 +28,12 @@ module Admin
format.json { render json: Event.where(state: :confirmed, program: @program).to_json }
format.xlsx do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\""
render 'events'
render 'events', layout: false
end
format.pdf { render 'events' }
format.pdf { render 'events', layout: false }
format.csv do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
render 'events'
render 'events', layout: false
end
end
end

View file

@ -23,12 +23,6 @@ module Admin
end
end
def edit
end
def show
end
def update
@registration_period.assign_attributes(registration_period_params)
send_mail_on_reg_update = @conference.notify_on_registration_dates_changed?

View file

@ -15,12 +15,22 @@ module Admin
@registration_distribution = @conference.registration_distribution
@affiliation_distribution = @conference.affiliation_distribution
@code_of_conduct = @conference.code_of_conduct.present?
@file_name = "registrations_for_#{@conference.short_title}"
respond_to do |format|
format.html
format.json do
render json: RegistrationDatatable.new(view_context, conference: @conference)
end
format.pdf { render 'index', layout: false }
format.xlsx do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\""
render 'index', layout: false
end
format.csv do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
render 'index', layout: false
end
end
end

View file

@ -15,8 +15,9 @@ module Admin
attended_registrants_ids = @conference.registrations.where(attended: true).pluck(:user_id)
@missing_event_speakers = EventUser.joins(:event)
.where('event_role = ? and program_id = ?', 'submitter', @program.id)
.where('event_role = ? and program_id = ?', 'speaker', @program.id)
.where.not(user_id: attended_registrants_ids)
.where(event_id: @events.pluck(:id))
.includes(:user, :event)
end
end

View file

@ -19,7 +19,7 @@ module Admin
if @survey.save
redirect_to new_admin_conference_survey_survey_question_path(@conference.short_title, @survey), notice: 'Successfully created survey'
else
redirect_to new_admin_conference_survey_survey_question_path(@conference.short_title, @survey), error: 'Could not create survey.' + @survey.errors.full_messages.to_sentence
redirect_to new_admin_conference_survey_path(@conference.short_title, survey: { surveyable_type: survey_params['surveyable_type'], surveyable_id: survey_params['surveyable_id'] }), error: 'Could not create survey.' + @survey.errors.full_messages.to_sentence
end
end

View file

@ -19,12 +19,12 @@ module Admin
format.json { render json: Track.where(state: :confirmed, program: @program).to_json }
format.xlsx do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.xlsx\""
render 'tracks'
render 'tracks', layout: false
end
format.pdf { render 'tracks' }
format.pdf { render 'tracks', layout: false }
format.csv do
response.headers['Content-Disposition'] = "attachment; filename=\"#{@file_name}.csv\""
render 'tracks'
render 'tracks', layout: false
end
end
end

View file

@ -40,9 +40,9 @@ module Admin
def render_commercial
result = Commercial.render_from_url(params[:url])
if result[:error]
render text: result[:error], status: 400
render plain: result[:error], status: 400
else
render text: result[:html]
render plain: result[:html]
end
end

View file

@ -23,9 +23,9 @@ class BoothsController < ApplicationController
if @booth.save
redirect_to conference_booths_path,
notice: 'Booth successfully created.'
notice: "#{(t 'booth').capitalize} successfully created."
else
flash.now[:error] = "Creating booth failed. #{@booth.errors.full_messages.to_sentence}."
flash.now[:error] = "Creating #{t 'booth'} failed. #{@booth.errors.full_messages.to_sentence}."
render :new
end
end
@ -43,6 +43,7 @@ class BoothsController < ApplicationController
notice: 'Booth successfully updated!'
else
flash.now[:error] = "Booth could not be updated. #{@booth.errors.full_messages.to_sentence}."
render :edit
end
end

View file

@ -4,6 +4,7 @@ class CommercialsController < ApplicationController
load_resource :conference, find_by: :short_title
before_action :set_event
load_and_authorize_resource through: :event
skip_before_action :verify_authenticity_token
def create
@commercial = @event.commercials.build(commercial_params)
@ -37,9 +38,9 @@ class CommercialsController < ApplicationController
def render_commercial
result = Commercial.render_from_url(params[:url])
if result[:error]
render text: result[:error], status: 400
render plain: result[:error], status: 400
else
render text: result[:html]
render plain: result[:html]
end
end

View file

@ -6,9 +6,8 @@ class ConferencesController < ApplicationController
load_and_authorize_resource find_by: :short_title, except: :show
def index
@current, @antiquated = Conference.reorder(start_date: :asc).all.partition do |conference|
conference.end_date >= Date.current
end
@current = Conference.where('end_date >= ?', Date.current).reorder(start_date: :asc)
@antiquated = Conference.where('end_date < ?', Date.current)
end
def show

View file

@ -6,6 +6,6 @@ class OpenidsController < ApplicationController
def destroy
@openid.destroy
redirect_to :back
redirect_back(fallback_location: root_path)
end
end

View file

@ -104,7 +104,7 @@ class ProposalsController < ApplicationController
@event.event_schedules.destroy_all
end
rescue Transitions::InvalidTransition
redirect_to :back, error: "Event can't be withdrawn"
redirect_back(fallback_location: root_path, error: "Event can't be withdrawn")
return
end
@ -124,7 +124,7 @@ class ProposalsController < ApplicationController
begin
@event.confirm
rescue Transitions::InvalidTransition
redirect_to :back, error: "Event can't be confirmed"
redirect_back(fallback_location: root_path, error: "Event can't be confirmed")
return
end

View file

@ -2,7 +2,6 @@
class SchedulesController < ApplicationController
load_and_authorize_resource
protect_from_forgery with: :null_session
before_action :respond_to_options
load_resource :conference, find_by: :short_title
load_resource :program, through: :conference, singleton: true, except: :index
@ -61,6 +60,10 @@ class SchedulesController < ApplicationController
@tag = day.strftime('%Y-%m-%d') if day
end
def app
@qr_code = RQRCode::QRCode.new(conference_schedule_url).as_svg(offset: 20, color: '000', shape_rendering: 'crispEdges', module_size: 11)
end
private
def respond_to_options

View file

@ -40,6 +40,6 @@ class SurveysController < ApplicationController
end
end
redirect_to :back
redirect_back(fallback_location: root_path)
end
end

View file

@ -16,9 +16,11 @@ class TicketPurchasesController < ApplicationController
elsif current_user.ticket_purchases.by_conference(@conference).paid.any?
redirect_to conference_physical_tickets_path,
notice: 'You have free tickets for the conference.'
else
elsif @conference.tickets.for_registration.any?
redirect_to conference_tickets_path(@conference.short_title),
error: 'Please get at least one ticket to continue.'
else
redirect_to conference_conference_registration_path(@conference.short_title)
end
else
redirect_to conference_tickets_path(@conference.short_title),

View file

@ -2,7 +2,7 @@
module Users
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_filter :verify_authenticity_token
skip_before_action :verify_authenticity_token
skip_authorization_check
User.omniauth_providers.each do |provider|
@ -35,8 +35,7 @@ module Users
openid.save!
sign_in user
redirect_to request.env['omniauth.origin'] || root_path,
notice: "#{user.email} signed in successfully with #{provider}"
redirect_to root_path, notice: "#{user.email} signed in successfully with #{provider}"
rescue => e
flash[:error] = e.message
redirect_back_or_to new_user_registration_path