mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 22:21:11 +00:00
Rubocop autocorrections
This commit is contained in:
parent
299738f58d
commit
43bef689fc
85 changed files with 622 additions and 578 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue