commit
68efa06696
2 changed files with 46 additions and 40 deletions
|
|
@ -119,17 +119,10 @@ class Conference < ActiveRecord::Base
|
||||||
# ====Args
|
# ====Args
|
||||||
# * +user+ -> The user we check for
|
# * +user+ -> The user we check for
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +nil+ -> If the user doesn't exist
|
|
||||||
# * +false+ -> If the user is registered
|
# * +false+ -> If the user is registered
|
||||||
# * +true+ - If the user isn't registered
|
# * +true+ - If the user isn't registered
|
||||||
def user_registered? user
|
def user_registered? user
|
||||||
return nil if user.nil?
|
user.present? && registrations.where(user_id: user.id).count > 0
|
||||||
|
|
||||||
if registrations.where(user_id: user.id).count == 0
|
|
||||||
return false
|
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -163,13 +156,9 @@ class Conference < ActiveRecord::Base
|
||||||
# * +false+ -> If the CFP is not set or today isn't in the CFP period.
|
# * +false+ -> If the CFP is not set or today isn't in the CFP period.
|
||||||
# * +true+ -> If today is in the CFP period.
|
# * +true+ -> If today is in the CFP period.
|
||||||
def cfp_open?
|
def cfp_open?
|
||||||
today = Date.current
|
|
||||||
cfp = self.call_for_paper
|
cfp = self.call_for_paper
|
||||||
if !cfp.nil? && (cfp.start_date.. cfp.end_date).cover?(today)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
cfp.present? && (cfp.start_date..cfp.end_date).cover?(Date.current)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -262,11 +251,11 @@ class Conference < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +Integer+ -> weeks
|
# * +Integer+ -> weeks
|
||||||
def cfp_weeks
|
def cfp_weeks
|
||||||
result = 0
|
|
||||||
if call_for_paper
|
if call_for_paper
|
||||||
result = call_for_paper.weeks
|
call_for_paper.weeks
|
||||||
|
else
|
||||||
|
0
|
||||||
end
|
end
|
||||||
result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -275,11 +264,11 @@ class Conference < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +Integer+ -> start week
|
# * +Integer+ -> start week
|
||||||
def get_registration_start_week
|
def get_registration_start_week
|
||||||
result = -1
|
|
||||||
if registration_period
|
if registration_period
|
||||||
result = registration_period.start_date.strftime('%W').to_i
|
registration_period.start_date.strftime('%W').to_i
|
||||||
|
else
|
||||||
|
-1
|
||||||
end
|
end
|
||||||
result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -288,11 +277,11 @@ class Conference < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +Integer+ -> start week
|
# * +Integer+ -> start week
|
||||||
def get_registration_end_week
|
def get_registration_end_week
|
||||||
result = -1
|
|
||||||
if registration_period
|
if registration_period
|
||||||
result = registration_period.end_date.strftime('%W').to_i
|
registration_period.end_date.strftime('%W').to_i
|
||||||
|
else
|
||||||
|
-1
|
||||||
end
|
end
|
||||||
result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -311,18 +300,21 @@ class Conference < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +hash+ -> true -> filled / false -> missing
|
# * +hash+ -> true -> filled / false -> missing
|
||||||
def get_status
|
def get_status
|
||||||
result = {}
|
result = {
|
||||||
result['registration'] = registration_date_set?
|
registration: registration_date_set?,
|
||||||
result['cfp'] = cfp_set?
|
cfp: cfp_set?,
|
||||||
result['venue'] = venue_set?
|
venue: venue_set?,
|
||||||
result['rooms'] = rooms_set?
|
rooms: rooms_set?,
|
||||||
result['tracks'] = tracks_set?
|
tracks: tracks_set?,
|
||||||
result['event_types'] = event_types_set?
|
event_types: event_types_set?,
|
||||||
result['difficulty_levels'] = difficulty_levels_set?
|
difficulty_levels: difficulty_levels_set?,
|
||||||
result['splashpage'] = splashpage && splashpage.public?
|
splashpage: splashpage && splashpage.public?
|
||||||
result['process'] = calculate_setup_progress(result)
|
}
|
||||||
result['short_title'] = short_title
|
|
||||||
result
|
result.update(
|
||||||
|
process: calculate_setup_progress(result),
|
||||||
|
short_title: short_title
|
||||||
|
).with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -492,11 +484,11 @@ class Conference < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +List+
|
# * +List+
|
||||||
def self.get_event_state_line_colors
|
def self.get_event_state_line_colors
|
||||||
result = []
|
[
|
||||||
result.push(short_title: 'Submitted', color: 'blue')
|
{ short_title: 'Submitted', color: 'blue' },
|
||||||
result.push(short_title: 'Confirmed', color: 'green')
|
{ short_title: 'Confirmed', color: 'green' },
|
||||||
result.push(short_title: 'Unconfirmed', color: 'orange')
|
{ short_title: 'Unconfirmed', color: 'orange' }
|
||||||
result
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -1463,8 +1463,22 @@ describe Conference do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'user is nil' do
|
||||||
|
it '#user_registered? is false' do
|
||||||
|
expect(subject.user_registered? user).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'user registered' do
|
context 'user registered' do
|
||||||
pending "isn't tested yet"
|
before do
|
||||||
|
registration = create(:registration)
|
||||||
|
subject.registrations << registration
|
||||||
|
user.registrations << registration
|
||||||
|
end
|
||||||
|
|
||||||
|
it '#user_registered? is true' do
|
||||||
|
expect(subject.user_registered? user).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue