Rubocop autocorrections
This commit is contained in:
parent
299738f58d
commit
43bef689fc
85 changed files with 622 additions and 578 deletions
|
|
@ -32,7 +32,7 @@ module Admin
|
|||
|
||||
def show
|
||||
@event_schedules = @schedule.event_schedules.eager_load(
|
||||
room: :tracks,
|
||||
room: :tracks,
|
||||
event: [
|
||||
:difficulty_level,
|
||||
:track,
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ module Admin
|
|||
|
||||
def sponsorship_level_required
|
||||
return unless @conference.sponsorship_levels.empty?
|
||||
|
||||
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
|
||||
alert: 'You need to create atleast one sponsorship level to add a sponsor'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ module Admin
|
|||
@conferences_with_role.uniq!
|
||||
|
||||
return if @conference.blank?
|
||||
|
||||
@versions = PaperTrail::Version.where(conference_id: @conference.id).accessible_by(current_ability)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class ApplicationController < ActionController::Base
|
|||
def store_location
|
||||
# store last url - this is needed for post-login redirect to whatever the user last visited.
|
||||
return unless request.get?
|
||||
|
||||
if (request.path != '/accounts/sign_in' &&
|
||||
request.path != '/accounts/sign_up' &&
|
||||
request.path != '/accounts/password/new' &&
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class PaymentsController < ApplicationController
|
|||
if @total_amount_to_pay.zero?
|
||||
raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment)
|
||||
end
|
||||
|
||||
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class PhysicalTicketsController < ApplicationController
|
|||
format.pdf do
|
||||
pdf = TicketPdf.new(@conference, @user, @physical_ticket, @ticket_layout, @file_name)
|
||||
send_data pdf.render,
|
||||
filename: @file_name,
|
||||
type: 'application/pdf',
|
||||
filename: @file_name,
|
||||
type: 'application/pdf',
|
||||
disposition: 'attachment'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ module ApplicationHelper
|
|||
|
||||
def concurrent_events(event)
|
||||
return nil unless event.scheduled? && event.program.selected_event_schedules
|
||||
|
||||
event_schedule = event.program.selected_event_schedules.find { |es| es.event == event }
|
||||
other_event_schedules = event.program.selected_event_schedules.reject { |other_event_schedule| other_event_schedule == event_schedule }
|
||||
concurrent_events = []
|
||||
|
|
@ -106,6 +107,7 @@ module ApplicationHelper
|
|||
event_time_range = (event_schedule.start_time.strftime '%Y-%m-%d %H:%M')...(event_schedule.end_time.strftime '%Y-%m-%d %H:%M')
|
||||
other_event_schedules.each do |other_event_schedule|
|
||||
next unless other_event_schedule.event.confirmed?
|
||||
|
||||
other_event_time_range = (other_event_schedule.start_time.strftime '%Y-%m-%d %H:%M')...(other_event_schedule.end_time.strftime '%Y-%m-%d %H:%M')
|
||||
if (event_time_range.to_a & other_event_time_range.to_a).present?
|
||||
concurrent_events << other_event_schedule.event
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ module DateTimeHelper
|
|||
# * +String+ -> formated datetime object
|
||||
def format_datetime(obj)
|
||||
return unless obj
|
||||
|
||||
obj.strftime('%Y-%m-%d %H:%M')
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ module EventsHelper
|
|||
# * +String+ -> number of registrations / max allowed registrations
|
||||
def registered_text(event)
|
||||
return "Registered: #{event.registrations.count}/#{event.max_attendees}" if event.max_attendees
|
||||
|
||||
"Registered: #{event.registrations.count}"
|
||||
end
|
||||
|
||||
|
|
@ -47,8 +48,8 @@ module EventsHelper
|
|||
|
||||
def track_selector_input(form)
|
||||
if @program.tracks.confirmed.cfp_active.any?
|
||||
form.input :track_id, as: :select,
|
||||
collection: @program.tracks.confirmed.cfp_active.pluck(:name, :id),
|
||||
form.input :track_id, as: :select,
|
||||
collection: @program.tracks.confirmed.cfp_active.pluck(:name, :id),
|
||||
include_blank: '(Please select)'
|
||||
end
|
||||
end
|
||||
|
|
@ -163,12 +164,12 @@ module EventsHelper
|
|||
conference_id,
|
||||
event.id,
|
||||
event.send(attribute),
|
||||
url: admin_conference_program_event_path(
|
||||
url: admin_conference_program_event_path(
|
||||
conference_id,
|
||||
event,
|
||||
event: { attribute => nil }
|
||||
),
|
||||
class: 'switch-checkbox'
|
||||
class: 'switch-checkbox'
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -191,9 +191,9 @@ module FormatHelper
|
|||
return '' if text.nil?
|
||||
|
||||
options = {
|
||||
autolink: true,
|
||||
autolink: true,
|
||||
space_after_headers: true,
|
||||
no_intra_emphasis: true
|
||||
no_intra_emphasis: true
|
||||
}
|
||||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: escape_html), options)
|
||||
markdown.render(text).html_safe
|
||||
|
|
@ -205,6 +205,7 @@ module FormatHelper
|
|||
|
||||
def quantity_left_of(resource)
|
||||
return '-/-' if resource.quantity.blank?
|
||||
|
||||
"#{resource.quantity - resource.used}/#{resource.quantity}"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ module VersionsHelper
|
|||
|
||||
org = Organization.find_by(id: organization_id)
|
||||
return current_or_last_object_state('Organization', organization_id).try(:name) unless org
|
||||
|
||||
org.name.to_s
|
||||
end
|
||||
|
||||
|
|
@ -47,6 +48,7 @@ module VersionsHelper
|
|||
# Otherwise Returns object state just before deletion
|
||||
def current_or_last_object_state(model_name, id)
|
||||
return nil unless id.present? && model_name.present?
|
||||
|
||||
begin
|
||||
object = model_name.constantize.find_by(id: id)
|
||||
rescue NameError
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
class Mailbot < ActionMailer::Base
|
||||
def registration_mail(conference, user)
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.registration_subject,
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.registration_body))
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.registration_body))
|
||||
end
|
||||
|
||||
def ticket_confirmation_mail(ticket_purchase)
|
||||
|
|
@ -20,110 +20,110 @@ class Mailbot < ActionMailer::Base
|
|||
attachments["ticket_for_#{@conference.short_title}_#{physical_ticket.id}.pdf"] = pdf.render
|
||||
end
|
||||
|
||||
mail(to: @user.email,
|
||||
from: @conference.contact.email,
|
||||
mail(to: @user.email,
|
||||
from: @conference.contact.email,
|
||||
template_name: 'ticket_confirmation_template',
|
||||
subject: "#{@conference.title} | Ticket Confirmation and PDF!")
|
||||
subject: "#{@conference.title} | Ticket Confirmation and PDF!")
|
||||
end
|
||||
|
||||
def acceptance_mail(event)
|
||||
conference = event.program.conference
|
||||
|
||||
mail(to: event.submitter.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: event.submitter.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.accepted_subject,
|
||||
body: conference.email_settings.generate_event_mail(event, conference.email_settings.accepted_body))
|
||||
body: conference.email_settings.generate_event_mail(event, conference.email_settings.accepted_body))
|
||||
end
|
||||
|
||||
def submitted_proposal_mail(event)
|
||||
conference = event.program.conference
|
||||
|
||||
mail(to: event.submitter.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: event.submitter.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.submitted_proposal_subject,
|
||||
body: conference.email_settings.generate_event_mail(event, conference.email_settings.submitted_proposal_body))
|
||||
body: conference.email_settings.generate_event_mail(event, conference.email_settings.submitted_proposal_body))
|
||||
end
|
||||
|
||||
def rejection_mail(event)
|
||||
conference = event.program.conference
|
||||
|
||||
mail(to: event.submitter.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: event.submitter.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.rejected_subject,
|
||||
body: conference.email_settings.generate_event_mail(event, conference.email_settings.rejected_body))
|
||||
body: conference.email_settings.generate_event_mail(event, conference.email_settings.rejected_body))
|
||||
end
|
||||
|
||||
def confirm_reminder_mail(event)
|
||||
conference = event.program.conference
|
||||
|
||||
mail(to: event.submitter.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: event.submitter.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.confirmed_without_registration_subject,
|
||||
body: conference.email_settings.generate_event_mail(event,
|
||||
conference.email_settings.confirmed_without_registration_body))
|
||||
body: conference.email_settings.generate_event_mail(event,
|
||||
conference.email_settings.confirmed_without_registration_body))
|
||||
end
|
||||
|
||||
def conference_date_update_mail(conference, user)
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.conference_dates_updated_subject,
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.conference_dates_updated_body))
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.conference_dates_updated_body))
|
||||
end
|
||||
|
||||
def conference_registration_date_update_mail(conference, user)
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.conference_registration_dates_updated_subject,
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.conference_registration_dates_updated_body))
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.conference_registration_dates_updated_body))
|
||||
end
|
||||
|
||||
def conference_venue_update_mail(conference, user)
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.venue_updated_subject,
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.venue_updated_body))
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.venue_updated_body))
|
||||
end
|
||||
|
||||
def conference_schedule_update_mail(conference, user)
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.program_schedule_public_subject,
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.program_schedule_public_body))
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.program_schedule_public_body))
|
||||
end
|
||||
|
||||
def conference_cfp_update_mail(conference, user)
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: user.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.cfp_dates_updated_subject,
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.cfp_dates_updated_body))
|
||||
body: conference.email_settings.generate_email_on_conf_updates(conference,
|
||||
user,
|
||||
conference.email_settings.cfp_dates_updated_body))
|
||||
end
|
||||
|
||||
def conference_booths_acceptance_mail(booth)
|
||||
conference = booth.conference
|
||||
|
||||
mail(to: booth.submitter.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: booth.submitter.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.booths_acceptance_subject,
|
||||
body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_acceptance_body))
|
||||
body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_acceptance_body))
|
||||
end
|
||||
|
||||
def conference_booths_rejection_mail(booth)
|
||||
conference = booth.conference
|
||||
|
||||
mail(to: booth.submitter.email,
|
||||
from: conference.contact.email,
|
||||
mail(to: booth.submitter.email,
|
||||
from: conference.contact.email,
|
||||
subject: conference.email_settings.booths_rejection_subject,
|
||||
body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_rejection_body))
|
||||
body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_rejection_body))
|
||||
end
|
||||
|
||||
def event_comment_mail(comment, user)
|
||||
|
|
@ -132,9 +132,9 @@ class Mailbot < ActionMailer::Base
|
|||
@conference = @event.program.conference
|
||||
@user = user
|
||||
|
||||
mail(to: @user.email,
|
||||
from: @conference.contact.email,
|
||||
mail(to: @user.email,
|
||||
from: @conference.contact.email,
|
||||
template_name: 'comment_template',
|
||||
subject: "New comment has been posted for #{@event.title}")
|
||||
subject: "New comment has been posted for #{@event.title}")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -150,13 +150,13 @@ class Ability
|
|||
can :manage, Event, program: { conference_id: conf_ids_for_organizer }
|
||||
# To access comment link in menu bar
|
||||
can :index, Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
|
||||
end
|
||||
|
||||
if conf_ids_for_cfp
|
||||
# To access comment link in menu bar
|
||||
can :index, Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
# To access conference/proposals
|
||||
can :manage, Event, program: { conference_id: conf_ids_for_cfp }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class AdminAbility
|
|||
can :manage, Contact, conference_id: conf_ids
|
||||
can :manage, EmailSettings, conference_id: conf_ids
|
||||
can :manage, Commercial, commercialable_type: 'Conference',
|
||||
commercialable_id: conf_ids
|
||||
commercialable_id: conf_ids
|
||||
can :manage, Registration, conference_id: conf_ids
|
||||
can :manage, RegistrationPeriod do |registration_period|
|
||||
conference = registration_period.conference
|
||||
|
|
@ -137,10 +137,10 @@ class AdminAbility
|
|||
can :manage, Track, program: { conference_id: conf_ids }
|
||||
can :manage, DifficultyLevel, program: { conference_id: conf_ids }
|
||||
can :manage, Commercial, commercialable_type: 'Event',
|
||||
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
|
||||
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
|
||||
can :manage, Venue, conference_id: conf_ids
|
||||
can :manage, Commercial, commercialable_type: 'Venue',
|
||||
commercialable_id: Venue.where(conference_id: conf_ids).pluck(:id)
|
||||
commercialable_id: Venue.where(conference_id: conf_ids).pluck(:id)
|
||||
can :manage, Lodging, conference_id: conf_ids
|
||||
can :manage, Room, venue: { conference_id: conf_ids }
|
||||
can :manage, Sponsor, conference_id: conf_ids
|
||||
|
|
@ -151,7 +151,7 @@ class AdminAbility
|
|||
conf_ids.include? conf_id
|
||||
end
|
||||
can :index, Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
|
|
@ -188,9 +188,9 @@ class AdminAbility
|
|||
can :manage, Cfp, program: { conference_id: conf_ids_for_cfp }
|
||||
can :manage, Program, conference_id: conf_ids_for_cfp
|
||||
can :manage, Commercial, commercialable_type: 'Event',
|
||||
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
can :index, Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
|
||||
|
||||
# Abilities for Role (Conference resource)
|
||||
can [:index, :show], Role do |role|
|
||||
|
|
@ -306,7 +306,7 @@ class AdminAbility
|
|||
|
||||
can :manage, Event, track_id: track_ids_for_track_organizer
|
||||
can :manage, Commercial, commercialable_type: 'Event',
|
||||
commercialable_id: Event.where(track_id: track_ids_for_track_organizer).pluck(:id)
|
||||
commercialable_id: Event.where(track_id: track_ids_for_track_organizer).pluck(:id)
|
||||
|
||||
# Show Scheduless in the admin sidebar
|
||||
can :update, Schedule do |schedule|
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class Booth < ApplicationRecord
|
|||
|
||||
validates :title,
|
||||
uniqueness: { case_sensitive: false },
|
||||
presence: true
|
||||
presence: true
|
||||
|
||||
validates :description,
|
||||
:reasoning,
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ class Cfp < ApplicationRecord
|
|||
validate :before_end_of_conference
|
||||
validate :start_after_end_date
|
||||
validates :cfp_type,
|
||||
presence: true,
|
||||
inclusion: {
|
||||
presence: true,
|
||||
inclusion: {
|
||||
in: TYPES
|
||||
},
|
||||
uniqueness: {
|
||||
scope: :program,
|
||||
scope: :program,
|
||||
case_sensitive: false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ class Comment < ApplicationRecord
|
|||
def self.build_from(obj, user_id, comment)
|
||||
new \
|
||||
commentable: obj,
|
||||
body: comment,
|
||||
user_id: user_id
|
||||
body: comment,
|
||||
user_id: user_id
|
||||
end
|
||||
|
||||
#helper method to check if a comment has children
|
||||
|
|
|
|||
|
|
@ -344,18 +344,18 @@ class Conference < ApplicationRecord
|
|||
# * +hash+ -> true -> filled / false -> missing
|
||||
def get_status
|
||||
result = {
|
||||
registration: registration_date_set?,
|
||||
cfp: cfp_set?,
|
||||
venue: venue_set?,
|
||||
rooms: rooms_set?,
|
||||
tracks: tracks_set?,
|
||||
event_types: event_types_set?,
|
||||
registration: registration_date_set?,
|
||||
cfp: cfp_set?,
|
||||
venue: venue_set?,
|
||||
rooms: rooms_set?,
|
||||
tracks: tracks_set?,
|
||||
event_types: event_types_set?,
|
||||
difficulty_levels: difficulty_levels_set?,
|
||||
splashpage: splashpage&.public?
|
||||
splashpage: splashpage&.public?
|
||||
}
|
||||
|
||||
result.update(
|
||||
process: calculate_setup_progress(result),
|
||||
process: calculate_setup_progress(result),
|
||||
short_title: short_title
|
||||
).with_indifferent_access
|
||||
end
|
||||
|
|
@ -670,6 +670,7 @@ class Conference < ApplicationRecord
|
|||
return false unless email_settings.send_on_conference_dates_updated
|
||||
# do not notify unless one of the dates changed
|
||||
return false unless start_date_changed? || end_date_changed?
|
||||
|
||||
# do not notify unless the mail content is set up
|
||||
(email_settings.conference_dates_updated_subject.present? && email_settings.conference_dates_updated_body.present?)
|
||||
end
|
||||
|
|
@ -686,6 +687,7 @@ class Conference < ApplicationRecord
|
|||
return false unless registration_period
|
||||
# do not notify unless one of the dates changed
|
||||
return false unless registration_period.start_date_changed? || registration_period.end_date_changed?
|
||||
|
||||
# do not notify unless the mail content is set up
|
||||
(email_settings.conference_registration_dates_updated_subject.present? && email_settings.conference_registration_dates_updated_body.present?)
|
||||
end
|
||||
|
|
@ -710,7 +712,7 @@ class Conference < ApplicationRecord
|
|||
start_index = {
|
||||
tracks: (program.tracks.count + 1),
|
||||
levels: (program.difficulty_levels.count + 51),
|
||||
types: (program.event_types.count + 101)
|
||||
types: (program.event_types.count + 101)
|
||||
}
|
||||
next_color(start_index[collection])
|
||||
end
|
||||
|
|
@ -842,8 +844,8 @@ class Conference < ApplicationRecord
|
|||
# * +Hash+ -> e.g. 'Confirmed' => { 3 => 5, 4 => 6 }
|
||||
def get_events_per_week_by_state
|
||||
result = {
|
||||
'Submitted' => {},
|
||||
'Confirmed' => {},
|
||||
'Submitted' => {},
|
||||
'Confirmed' => {},
|
||||
'Unconfirmed' => {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class Contact < ApplicationRecord
|
|||
|
||||
def has_social_media?
|
||||
return true if facebook.present? || twitter.present? || googleplus.present? || instagram.present? || mastodon.present? || email.present?
|
||||
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,17 +7,17 @@ class EmailSettings < ApplicationRecord
|
|||
|
||||
def get_values(conference, user, event = nil, booth = nil)
|
||||
h = {
|
||||
'email' => user.email,
|
||||
'name' => user.name,
|
||||
'conference' => conference.title,
|
||||
'conference_start_date' => conference.start_date,
|
||||
'conference_end_date' => conference.end_date,
|
||||
'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registration_url(
|
||||
'email' => user.email,
|
||||
'name' => user.name,
|
||||
'conference' => conference.title,
|
||||
'conference_start_date' => conference.start_date,
|
||||
'conference_end_date' => conference.end_date,
|
||||
'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registration_url(
|
||||
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
|
||||
'conference_splash_link' => Rails.application.routes.url_helpers.conference_url(
|
||||
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
|
||||
|
||||
'schedule_link' => Rails.application.routes.url_helpers.conference_schedule_url(
|
||||
'schedule_link' => Rails.application.routes.url_helpers.conference_schedule_url(
|
||||
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000'))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ class Event < ApplicationRecord
|
|||
def registration_possible?
|
||||
return false unless require_registration && state == 'confirmed'
|
||||
return true if max_attendees.nil?
|
||||
|
||||
registrations.count < max_attendees
|
||||
end
|
||||
|
||||
|
|
@ -228,14 +229,14 @@ class Event < ApplicationRecord
|
|||
# Returns +Hash+
|
||||
def progress_status
|
||||
{
|
||||
registered: speakers.all? { |speaker| program.conference.user_registered? speaker },
|
||||
commercials: commercials.any?,
|
||||
biographies: speakers.all? { |speaker| !speaker.biography.blank? },
|
||||
subtitle: !subtitle.blank?,
|
||||
track: (!track.blank? unless program.tracks.empty?),
|
||||
registered: speakers.all? { |speaker| program.conference.user_registered? speaker },
|
||||
commercials: commercials.any?,
|
||||
biographies: speakers.all? { |speaker| !speaker.biography.blank? },
|
||||
subtitle: !subtitle.blank?,
|
||||
track: (!track.blank? unless program.tracks.empty?),
|
||||
difficulty_level: !difficulty_level.blank?,
|
||||
title: true,
|
||||
abstract: true
|
||||
title: true,
|
||||
abstract: true
|
||||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
|
|
@ -278,6 +279,7 @@ class Event < ApplicationRecord
|
|||
def ended?
|
||||
event_schedule = event_schedules.find_by(schedule_id: selected_schedule_id)
|
||||
return false unless event_schedule
|
||||
|
||||
event_schedule.end_time < Time.current
|
||||
end
|
||||
|
||||
|
|
@ -291,12 +293,14 @@ class Event < ApplicationRecord
|
|||
# Do not allow, for the event, more attendees than the size of the room
|
||||
def max_attendees_no_more_than_room_size
|
||||
return unless room && max_attendees_changed?
|
||||
|
||||
errors.add(:max_attendees, "cannot be more than the room's capacity (#{room.size})") if max_attendees && (max_attendees > room.size)
|
||||
end
|
||||
|
||||
def abstract_limit
|
||||
# If we don't have an event type, there is no need to count anything
|
||||
return unless event_type && abstract
|
||||
|
||||
len = abstract.split.size
|
||||
max_words = event_type.maximum_abstract_length
|
||||
min_words = event_type.minimum_abstract_length
|
||||
|
|
@ -335,6 +339,7 @@ class Event < ApplicationRecord
|
|||
#
|
||||
def valid_track
|
||||
return unless track&.program && program
|
||||
|
||||
errors.add(:track, 'is invalid') unless track.confirmed? && track.program == program
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ class EventSchedule < ApplicationRecord
|
|||
def replacement?(event_schedule_source = nil)
|
||||
return false unless event.state == 'confirmed'
|
||||
return replaced_event_schedules.exists? unless event_schedule_source
|
||||
|
||||
event_schedule_source.any? { |event_schedule| intersects_with?(event_schedule) }
|
||||
end
|
||||
|
||||
|
|
@ -82,11 +83,13 @@ class EventSchedule < ApplicationRecord
|
|||
|
||||
def start_after_end_hour
|
||||
return unless event && start_time && event.program && event.program.conference && event.program.conference.end_hour
|
||||
|
||||
errors.add(:start_time, "can't be after the conference end hour (#{event.program.conference.end_hour})") if start_time.hour >= event.program.conference.end_hour
|
||||
end
|
||||
|
||||
def start_before_start_hour
|
||||
return unless event && start_time && event.program && event.program.conference && event.program.conference.start_hour
|
||||
|
||||
errors.add(:start_time, "can't be before the conference start hour (#{event.program.conference.start_hour})") if start_time.hour < event.program.conference.start_hour
|
||||
end
|
||||
|
||||
|
|
@ -99,6 +102,7 @@ class EventSchedule < ApplicationRecord
|
|||
#
|
||||
def same_room_as_track
|
||||
return unless event.try(:track).try(:room)
|
||||
|
||||
errors.add(:room, "must be the same as the track's room (#{event.track.room.name})") unless event.track.room == room
|
||||
end
|
||||
|
||||
|
|
@ -122,6 +126,7 @@ class EventSchedule < ApplicationRecord
|
|||
#
|
||||
def valid_schedule
|
||||
return unless event.try(:track).try(:self_organized?) && schedule
|
||||
|
||||
errors.add(:schedule, "must be one of #{event.track.name} track's schedules") unless event.track.schedules.include?(schedule)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class EventType < ApplicationRecord
|
|||
belongs_to :program, touch: true
|
||||
has_many :events, dependent: :restrict_with_error
|
||||
|
||||
has_paper_trail meta: { conference_id: :conference_id },
|
||||
has_paper_trail meta: { conference_id: :conference_id },
|
||||
ignore: %i[updated_at]
|
||||
|
||||
validates :title, presence: true
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class Organization < ApplicationRecord
|
|||
uniqueness: {
|
||||
case_sensitive: false
|
||||
},
|
||||
presence: true
|
||||
presence: true
|
||||
|
||||
mount_uploader :picture, PictureUploader, mount_on: :picture
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class Payment < ApplicationRecord
|
|||
validates :conference_id, presence: true
|
||||
|
||||
enum status: {
|
||||
unpaid: 0,
|
||||
unpaid: 0,
|
||||
success: 1,
|
||||
failure: 2
|
||||
}
|
||||
|
|
@ -23,11 +23,11 @@ class Payment < ApplicationRecord
|
|||
end
|
||||
|
||||
def purchase
|
||||
gateway_response = Stripe::Charge.create source: stripe_customer_token,
|
||||
gateway_response = Stripe::Charge.create source: stripe_customer_token,
|
||||
receipt_email: stripe_customer_email,
|
||||
description: "ticket purchases(#{user.username})",
|
||||
amount: amount_to_pay,
|
||||
currency: conference.tickets.first.price_currency
|
||||
description: "ticket purchases(#{user.username})",
|
||||
amount: amount_to_pay,
|
||||
currency: conference.tickets.first.price_currency
|
||||
|
||||
self.amount = gateway_response[:amount]
|
||||
self.last4 = gateway_response[:source][:last4]
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ class Program < ApplicationRecord
|
|||
event_schedules = selected_schedule.event_schedules.includes(*includes).order(start_time: :asc) if selected_schedule
|
||||
tracks.self_organized.confirmed.includes(selected_schedule: { event_schedules: includes }).order(start_date: :asc).each do |track|
|
||||
next unless track.selected_schedule
|
||||
|
||||
event_schedules += track.selected_schedule.event_schedules
|
||||
end
|
||||
event_schedules.sort_by(&:start_time)
|
||||
|
|
@ -157,6 +158,7 @@ class Program < ApplicationRecord
|
|||
return false unless conference.email_settings.send_on_program_schedule_public
|
||||
# do not notify if the schedule is not public
|
||||
return false unless schedule_public
|
||||
|
||||
# do not notify unless the mail content is set up
|
||||
(!conference.email_settings.program_schedule_public_subject.blank? && !conference.email_settings.program_schedule_public_body.blank?)
|
||||
end
|
||||
|
|
@ -173,6 +175,7 @@ class Program < ApplicationRecord
|
|||
# * +False+ -> If there is not any event for the given date
|
||||
def any_event_for_this_date?(date)
|
||||
return false unless selected_schedule.present?
|
||||
|
||||
parsed_date = DateTime.parse("#{date} 00:00").utc
|
||||
range = parsed_date..(parsed_date + 1.day)
|
||||
selected_schedule.event_schedules.any? { |es| range.cover?(es.start_time) }
|
||||
|
|
@ -185,6 +188,7 @@ class Program < ApplicationRecord
|
|||
# * +ActiveRecord+ -> The program's cfp with cfp_type == 'events'
|
||||
def cfp
|
||||
return nil if cfps.for_events.blank?
|
||||
|
||||
cfps.for_events
|
||||
end
|
||||
|
||||
|
|
@ -231,6 +235,7 @@ class Program < ApplicationRecord
|
|||
#
|
||||
def check_languages_format
|
||||
return unless languages.present?
|
||||
|
||||
# All white spaces are removed to allow languages to be separated by ',' and ', '. The languages string without spaces is saved
|
||||
self.languages = languages.delete(' ').downcase
|
||||
errors.add(:languages, 'must be two letters separated by commas') && return unless
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class Survey < ActiveRecord::Base
|
|||
# * +false+ -> If the survey is closed
|
||||
def active?
|
||||
return true unless start_date || end_date
|
||||
|
||||
# Find timezone of conference (survyeable is Conference or Event)
|
||||
timezone = surveyable.is_a?(Conference) ? surveyable.timezone : surveyable.conference.timezone
|
||||
now = Time.current.in_time_zone(timezone)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class Ticket < ApplicationRecord
|
|||
has_many :ticket_purchases, dependent: :destroy
|
||||
has_many :buyers, -> { distinct }, through: :ticket_purchases, source: :user
|
||||
|
||||
has_paper_trail meta: { conference_id: :conference_id },
|
||||
has_paper_trail meta: { conference_id: :conference_id },
|
||||
ignore: %i[updated_at]
|
||||
|
||||
monetize :price_cents, with_model_currency: :price_currency
|
||||
|
|
@ -66,6 +66,7 @@ class Ticket < ApplicationRecord
|
|||
def tickets_turnover_total(id)
|
||||
ticket = Ticket.find(id)
|
||||
return Money.new(0, 'USD') unless ticket
|
||||
|
||||
sum = ticket.ticket_purchases.paid.total
|
||||
Money.new(sum, ticket.price_currency)
|
||||
end
|
||||
|
|
@ -79,6 +80,7 @@ class Ticket < ApplicationRecord
|
|||
def tickets_of_conference_have_same_currency
|
||||
tickets = Ticket.where(conference_id: conference_id)
|
||||
return if tickets.count.zero? || (tickets.count == 1 && self == tickets.first)
|
||||
|
||||
unless tickets.all?{|t| t.price_currency == price_currency }
|
||||
errors.add(:price_currency, 'is different from the existing tickets of this conference.')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -51,21 +51,21 @@ class TicketPurchase < ApplicationRecord
|
|||
|
||||
def self.purchase_ticket(conference, quantity, ticket, user)
|
||||
if quantity > 0
|
||||
purchase = new(ticket_id: ticket.id,
|
||||
purchase = new(ticket_id: ticket.id,
|
||||
conference_id: conference.id,
|
||||
user_id: user.id,
|
||||
quantity: quantity,
|
||||
amount_paid: ticket.price)
|
||||
user_id: user.id,
|
||||
quantity: quantity,
|
||||
amount_paid: ticket.price)
|
||||
purchase.pay(nil) if ticket.price_cents.zero?
|
||||
end
|
||||
purchase
|
||||
end
|
||||
|
||||
def self.update_quantity(conference, quantity, ticket, user)
|
||||
purchase = TicketPurchase.where(ticket_id: ticket.id,
|
||||
purchase = TicketPurchase.where(ticket_id: ticket.id,
|
||||
conference_id: conference.id,
|
||||
user_id: user.id,
|
||||
paid: false).first
|
||||
user_id: user.id,
|
||||
paid: false).first
|
||||
|
||||
purchase.quantity = quantity if quantity > 0
|
||||
purchase
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ class Track < ApplicationRecord
|
|||
validates :name, presence: true
|
||||
validates :color, format: /\A#[0-9A-F]{6}\z/
|
||||
validates :short_name,
|
||||
presence: true,
|
||||
format: /\A[a-zA-Z0-9_-]*\z/,
|
||||
presence: true,
|
||||
format: /\A[a-zA-Z0-9_-]*\z/,
|
||||
uniqueness: {
|
||||
scope: :program
|
||||
}
|
||||
validates :state,
|
||||
presence: true,
|
||||
presence: true,
|
||||
inclusion: { in: %w(new to_accept accepted confirmed to_reject rejected canceled withdrawn) }
|
||||
validates :cfp_active, inclusion: { in: [true, false] }
|
||||
validates :start_date, presence: true, if: :self_organized_and_accepted_or_confirmed?
|
||||
|
|
@ -92,6 +92,7 @@ class Track < ApplicationRecord
|
|||
# * +false+ -> if the track doesn't have a submitter
|
||||
def self_organized?
|
||||
return true if submitter
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
|
|
@ -200,6 +201,7 @@ class Track < ApplicationRecord
|
|||
#
|
||||
def dates_within_conference_dates
|
||||
return unless start_date && end_date && program.try(:conference).try(:start_date) && program.try(:conference).try(:end_date)
|
||||
|
||||
errors.add(:start_date, "can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})") unless (program.conference.start_date..program.conference.end_date).cover?(start_date)
|
||||
errors.add(:end_date, "can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})") unless (program.conference.start_date..program.conference.end_date).cover?(end_date)
|
||||
end
|
||||
|
|
@ -209,6 +211,7 @@ class Track < ApplicationRecord
|
|||
#
|
||||
def start_date_before_end_date
|
||||
return unless start_date && end_date
|
||||
|
||||
errors.add(:start_date, 'can\'t be after the end date') if start_date > end_date
|
||||
end
|
||||
|
||||
|
|
@ -217,6 +220,7 @@ class Track < ApplicationRecord
|
|||
#
|
||||
def valid_room
|
||||
return unless room.try(:venue).try(:conference) && program.try(:conference)
|
||||
|
||||
errors.add(:room, "must be a room of #{program.conference.venue.name}") unless room.venue.conference == program.conference
|
||||
end
|
||||
|
||||
|
|
@ -225,8 +229,10 @@ class Track < ApplicationRecord
|
|||
#
|
||||
def overlapping
|
||||
return unless start_date && end_date && room && program.try(:tracks)
|
||||
|
||||
(program.tracks.accepted + program.tracks.confirmed - [self]).each do |existing_track|
|
||||
next unless existing_track.room == room && existing_track.start_date && existing_track.end_date
|
||||
|
||||
if start_date >= existing_track.start_date && start_date <= existing_track.end_date ||
|
||||
end_date >= existing_track.start_date && end_date <= existing_track.end_date ||
|
||||
start_date <= existing_track.start_date && end_date >= existing_track.end_date
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class User < ApplicationRecord
|
|||
uniqueness: {
|
||||
case_sensitive: false
|
||||
},
|
||||
presence: true
|
||||
presence: true
|
||||
|
||||
validate :biography_limit
|
||||
|
||||
|
|
@ -103,6 +103,7 @@ class User < ApplicationRecord
|
|||
event_registration = event.events_registrations.find_by(registration: registrations)
|
||||
|
||||
return false unless event_registration.present?
|
||||
|
||||
event_registration.attended
|
||||
end
|
||||
|
||||
|
|
@ -138,8 +139,8 @@ class User < ApplicationRecord
|
|||
raise UserDisabled if user&.is_disabled
|
||||
|
||||
if user
|
||||
user.update_attributes(email: attributes[:email],
|
||||
last_sign_in_at: user.current_sign_in_at,
|
||||
user.update_attributes(email: attributes[:email],
|
||||
last_sign_in_at: user.current_sign_in_at,
|
||||
current_sign_in_at: Time.current)
|
||||
else
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class Venue < ApplicationRecord
|
|||
return false unless conference.try(:email_settings).try(:send_on_venue_updated)
|
||||
# do not notify unless the address changed
|
||||
return false unless name_changed? || street_changed? || city_changed? || country_changed?
|
||||
|
||||
# do not notify unless the mail content is set up
|
||||
(!conference.email_settings.venue_updated_subject.blank? && !conference.email_settings.venue_updated_body.blank?)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,17 +7,17 @@ class ConferenceSerializer < ActiveModel::Serializer
|
|||
:date_range, :revision
|
||||
|
||||
def difficulty_levels
|
||||
object.program.difficulty_levels.map do |difficulty_level| { id: difficulty_level.id,
|
||||
title: difficulty_level.title,
|
||||
object.program.difficulty_levels.map do |difficulty_level| { id: difficulty_level.id,
|
||||
title: difficulty_level.title,
|
||||
description: difficulty_level.description
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def event_types
|
||||
object.program.event_types.map do |event_type| { id: event_type.id,
|
||||
title: event_type.title,
|
||||
length: event_type.length,
|
||||
object.program.event_types.map do |event_type| { id: event_type.id,
|
||||
title: event_type.title,
|
||||
length: event_type.length,
|
||||
description: event_type.description
|
||||
}
|
||||
end
|
||||
|
|
@ -25,20 +25,20 @@ class ConferenceSerializer < ActiveModel::Serializer
|
|||
|
||||
def rooms
|
||||
if object.venue
|
||||
object.venue.rooms.map do |room| { id: room.id,
|
||||
size: room.size,
|
||||
events: room.event_schedules.map do |event_schedule| { guid: event_schedule.event.title,
|
||||
title: event_schedule.event.title,
|
||||
subtitle: event_schedule.event.subtitle,
|
||||
abstract: event_schedule.event.abstract,
|
||||
description: event_schedule.event.description,
|
||||
is_highlight: event_schedule.event.is_highlight,
|
||||
require_registration: event_schedule.event.require_registration,
|
||||
start_time: event_schedule.start_time,
|
||||
event_type_id: event_schedule.event.event_type.id,
|
||||
difficulty_level_id: event_schedule.event.difficulty_level_id,
|
||||
track_id: event_schedule.event.track_id,
|
||||
speaker_names: event_schedule.event.speaker_names
|
||||
object.venue.rooms.map do |room| { id: room.id,
|
||||
size: room.size,
|
||||
events: room.event_schedules.map do |event_schedule| { guid: event_schedule.event.title,
|
||||
title: event_schedule.event.title,
|
||||
subtitle: event_schedule.event.subtitle,
|
||||
abstract: event_schedule.event.abstract,
|
||||
description: event_schedule.event.description,
|
||||
is_highlight: event_schedule.event.is_highlight,
|
||||
require_registration: event_schedule.event.require_registration,
|
||||
start_time: event_schedule.start_time,
|
||||
event_type_id: event_schedule.event.event_type.id,
|
||||
difficulty_level_id: event_schedule.event.difficulty_level_id,
|
||||
track_id: event_schedule.event.track_id,
|
||||
speaker_names: event_schedule.event.speaker_names
|
||||
}
|
||||
end
|
||||
}
|
||||
|
|
@ -49,8 +49,8 @@ class ConferenceSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def tracks
|
||||
object.program.tracks.map do |track| { 'id' => track.id,
|
||||
'name' => track.name,
|
||||
object.program.tracks.map do |track| { 'id' => track.id,
|
||||
'name' => track.name,
|
||||
'description' => track.description
|
||||
}
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue