parent
a620950383
commit
ed55e2bf3a
25 changed files with 529 additions and 131 deletions
|
|
@ -106,6 +106,7 @@ class Ability
|
|||
can :manage, Contact, conference_id: conf_ids_for_organizer
|
||||
can :manage, Campaign, conference_id: conf_ids_for_organizer
|
||||
can :manage, Photo, conference_id: conf_ids_for_organizer
|
||||
can :manage, RegistrationPeriod, conference_id: conf_ids_for_organizer
|
||||
end
|
||||
|
||||
def guest
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ class Conference < ActiveRecord::Base
|
|||
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
|
||||
:dietary_choices_attributes, :use_dietary_choices, :use_supporter_levels,
|
||||
:supporter_levels_attributes, :social_events_attributes, :event_types_attributes,
|
||||
:registration_start_date, :registration_end_date, :logo, :questions_attributes,
|
||||
:logo, :questions_attributes,
|
||||
:question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes,
|
||||
:use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes,
|
||||
:vpositions_attributes, :use_volunteers, :color,
|
||||
:description, :registration_description, :ticket_description,
|
||||
:description, :ticket_description,
|
||||
:sponsorship_levels_attributes, :sponsors_attributes,
|
||||
:sponsor_description, :sponsor_email, :lodging_description,
|
||||
:include_registrations_in_splash, :include_sponsors_in_splash,
|
||||
|
|
@ -29,7 +29,7 @@ class Conference < ActiveRecord::Base
|
|||
has_and_belongs_to_many :questions
|
||||
|
||||
has_one :contact, dependent: :destroy
|
||||
|
||||
has_one :registration_period, dependent: :destroy
|
||||
has_one :email_settings, dependent: :destroy
|
||||
has_one :call_for_papers, dependent: :destroy
|
||||
has_many :social_events, dependent: :destroy
|
||||
|
|
@ -128,8 +128,8 @@ class Conference < ActiveRecord::Base
|
|||
# * +true+ -> If today is in the registration period.
|
||||
def registration_open?
|
||||
today = Date.current
|
||||
if registration_dates_given?
|
||||
(registration_start_date..registration_end_date).cover?(today)
|
||||
if registration_period && registration_dates_given?
|
||||
(registration_period.start_date..registration_period.end_date).cover?(today)
|
||||
else
|
||||
false
|
||||
end
|
||||
|
|
@ -142,7 +142,7 @@ class Conference < ActiveRecord::Base
|
|||
# * +false+ -> If the conference registration dates are not set
|
||||
# * +true+ -> If conference registration dates are set
|
||||
def registration_dates_given?
|
||||
if registration_start_date.blank? || registration_end_date.blank?
|
||||
if registration_period && (registration_period.start_date.blank? || registration_period.end_date.blank?)
|
||||
false
|
||||
else
|
||||
true
|
||||
|
|
@ -218,8 +218,9 @@ class Conference < ActiveRecord::Base
|
|||
result = []
|
||||
|
||||
if registrations &&
|
||||
registration_start_date &&
|
||||
registration_end_date
|
||||
registration_period &&
|
||||
registration_period.start_date &&
|
||||
registration_period.end_date
|
||||
|
||||
reg = registrations.group(:week).count
|
||||
start_week = get_registration_start_week
|
||||
|
|
@ -237,8 +238,10 @@ class Conference < ActiveRecord::Base
|
|||
def registration_weeks
|
||||
result = 0
|
||||
weeks = 0
|
||||
if registration_start_date && registration_end_date
|
||||
weeks = Date.new(registration_start_date.year, 12, 31).
|
||||
if registration_period &&
|
||||
registration_period.start_date &&
|
||||
registration_period.end_date
|
||||
weeks = Date.new(registration_period.start_date.year, 12, 31).
|
||||
strftime('%W').to_i
|
||||
|
||||
result = get_registration_end_week - get_registration_start_week + 1
|
||||
|
|
@ -265,7 +268,11 @@ class Conference < ActiveRecord::Base
|
|||
# ====Returns
|
||||
# * +Integer+ -> start week
|
||||
def get_registration_start_week
|
||||
registration_start_date.strftime('%W').to_i
|
||||
result = -1
|
||||
if registration_period
|
||||
result = registration_period.start_date.strftime('%W').to_i
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
##
|
||||
|
|
@ -274,7 +281,11 @@ class Conference < ActiveRecord::Base
|
|||
# ====Returns
|
||||
# * +Integer+ -> start week
|
||||
def get_registration_end_week
|
||||
registration_end_date.strftime('%W').to_i
|
||||
result = -1
|
||||
if registration_period
|
||||
result = registration_period.end_date.strftime('%W').to_i
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
##
|
||||
|
|
@ -430,13 +441,11 @@ class Conference < ActiveRecord::Base
|
|||
# * +ActiveRecord+
|
||||
def self.get_active_conferences_for_dashboard
|
||||
result = Conference.where('start_date > ?', Time.now).
|
||||
select('id, short_title, color, start_date,
|
||||
registration_end_date, registration_start_date')
|
||||
select('id, short_title, color, start_date')
|
||||
|
||||
if result.length == 0
|
||||
result = Conference.
|
||||
select('id, short_title, color, start_date, registration_end_date,
|
||||
registration_start_date').limit(2).
|
||||
select('id, short_title, color, start_date').limit(2).
|
||||
order(start_date: :desc)
|
||||
end
|
||||
result
|
||||
|
|
@ -448,8 +457,7 @@ class Conference < ActiveRecord::Base
|
|||
# ====Returns
|
||||
# * +ActiveRecord+
|
||||
def self.get_conferences_without_active_for_dashboard(active_conferences)
|
||||
result = Conference.select('id, short_title, color, start_date,
|
||||
registration_end_date, registration_start_date').order(start_date: :desc)
|
||||
result = Conference.select('id, short_title, color, start_date').order(start_date: :desc)
|
||||
result - active_conferences
|
||||
end
|
||||
|
||||
|
|
@ -525,11 +533,11 @@ class Conference < ActiveRecord::Base
|
|||
# ====Returns
|
||||
# * +True+ -> If conference is updated and all other parameters are set
|
||||
# * +False+ -> Either conference is not updated or one or more parameter is not set
|
||||
def notify_on_dates_change?
|
||||
(self.start_date_changed? || self.end_date_changed?)\
|
||||
&& self.email_settings.send_on_updated_conference_dates\
|
||||
&& !self.email_settings.updated_conference_dates_subject.blank?\
|
||||
&& self.email_settings.updated_conference_dates_template
|
||||
def notify_on_dates_changed?
|
||||
(self.start_date_changed? || self.end_date_changed?) &&
|
||||
self.email_settings.send_on_updated_conference_dates &&
|
||||
!self.email_settings.updated_conference_dates_subject.blank? &&
|
||||
self.email_settings.updated_conference_dates_template
|
||||
end
|
||||
|
||||
##
|
||||
|
|
@ -539,10 +547,11 @@ class Conference < ActiveRecord::Base
|
|||
# * +True+ -> If registration dates is updated and all other parameters are set
|
||||
# * +False+ -> Either registration date is not updated or one or more parameter is not set
|
||||
def notify_on_registration_dates_changed?
|
||||
(self.registration_start_date_changed? || self.registration_end_date_changed?)\
|
||||
&& self.email_settings.send_on_updated_conference_registration_dates\
|
||||
&& !self.email_settings.updated_conference_registration_dates_subject.blank?\
|
||||
&& self.email_settings.updated_conference_registration_dates_template
|
||||
registration_period &&
|
||||
(registration_period.start_date_changed? || registration_period.end_date_changed?) &&
|
||||
email_settings.send_on_updated_conference_registration_dates &&
|
||||
!email_settings.updated_conference_registration_dates_subject.blank? &&
|
||||
email_settings.updated_conference_registration_dates_template
|
||||
end
|
||||
|
||||
private
|
||||
|
|
@ -737,7 +746,7 @@ class Conference < ActiveRecord::Base
|
|||
# * +True+ -> If conference has a start and a end date.
|
||||
# * +False+ -> If conference has no start or end date.
|
||||
def registration_date_set?
|
||||
!!registration_start_date && !!registration_end_date
|
||||
!!registration_period && !!registration_period.start_date && !!registration_period.end_date
|
||||
end
|
||||
|
||||
# Calculates the distribution from events.
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ class EmailSettings < ActiveRecord::Base
|
|||
'conference' => conference.title,
|
||||
'conference_start_date' => conference.start_date,
|
||||
'conference_end_date' => conference.end_date,
|
||||
'registration_start_date' => conference.registration_start_date,
|
||||
'registration_end_date' => conference.registration_end_date,
|
||||
'venue' => conference.venue.name,
|
||||
'venue_address' => conference.venue.address,
|
||||
'registrationlink' => Rails.application.routes.url_helpers.register_conference_url(
|
||||
|
|
@ -33,6 +31,11 @@ class EmailSettings < ActiveRecord::Base
|
|||
conference.short_title, host: CONFIG['url_for_emails'])
|
||||
}
|
||||
|
||||
if conference.registration_period
|
||||
h['registration_start_date'] = conference.registration_period.start_date
|
||||
h['registration_end_date'] = conference.registration_period.end_date
|
||||
end
|
||||
|
||||
if !event.nil?
|
||||
h['eventtitle'] = event.title
|
||||
h['proposalslink'] = Rails.application.routes.url_helpers.conference_proposal_url(
|
||||
|
|
|
|||
7
app/models/registration_period.rb
Normal file
7
app/models/registration_period.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class RegistrationPeriod < ActiveRecord::Base
|
||||
attr_accessible :description, :start_date, :end_date
|
||||
|
||||
validates :start_date, :end_date, presence: true
|
||||
|
||||
belongs_to :conference
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue