Starting to document things with rdoc
This commit is contained in:
parent
ad1121ffb0
commit
accd7d1a58
8 changed files with 108 additions and 360 deletions
34
app/helpers/home_helper.rb
Normal file
34
app/helpers/home_helper.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
##
|
||||
# This class contains helper for the home views.
|
||||
|
||||
module HomeHelper
|
||||
|
||||
##
|
||||
# Returns a string build from the start and end date of the given conference.
|
||||
#
|
||||
# If the conference starts and ends in the same month and year
|
||||
# * %B %d - %d, %Y (January 17 - 21 2014)
|
||||
# If the conference ends in another month but in the same year
|
||||
# * %B %d - %B %d, %Y (January 31 - February 02 2014)
|
||||
# All other cases
|
||||
# * %B %d, %Y - %B %d, %Y (December 30, 2013 - January 02, 2014)
|
||||
def conference_date_string(conf)
|
||||
startstr = "Unknown - "
|
||||
endstr = "Unknown"
|
||||
# When the conference in the same motn
|
||||
if conf.start_date.month == conf.end_date.month and conf.start_date.year == conf.end_date.year
|
||||
startstr = conf.start_date.strftime("%B %d - ")
|
||||
endstr = conf.end_date.strftime("%d, %Y")
|
||||
elsif conf.start_date.month != conf.end_date.month && conf.start_date.year == conf.end_date.year
|
||||
startstr = conf.start_date.strftime("%B %d - ")
|
||||
endstr = conf.end_date.strftime("%B %d, %Y")
|
||||
else
|
||||
startstr = conf.start_date.strftime("%B %d, %Y - ")
|
||||
endstr = conf.end_date.strftime("%B %d, %Y")
|
||||
end
|
||||
|
||||
result = startstr + endstr
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
##
|
||||
# This class represents a conference
|
||||
|
||||
class Conference < ActiveRecord::Base
|
||||
attr_accessible :title, :short_title, :social_tag, :contact_email, :timezone, :html_export_path,
|
||||
:start_date, :end_date, :rooms_attributes, :tracks_attributes, :dietary_choices_attributes,
|
||||
|
|
@ -61,41 +64,34 @@ class Conference < ActiveRecord::Base
|
|||
before_create :create_venue
|
||||
before_create :create_email_settings
|
||||
|
||||
def self.current
|
||||
self.order("created_at DESC").first
|
||||
end
|
||||
|
||||
def date_range_string
|
||||
startstr = "Unknown - "
|
||||
endstr = "Unknown"
|
||||
if start_date.month == end_date.month && start_date.year == end_date.year
|
||||
startstr = start_date.strftime("%B %d - ")
|
||||
endstr = end_date.strftime("%d, %Y")
|
||||
elsif start_date.month != end_date.month && start_date.year == end_date.year
|
||||
startstr = start_date.strftime("%B %d - ")
|
||||
endstr = end_date.strftime("%B %d, %Y")
|
||||
else
|
||||
startstr = start_date.strftime("%B %d, %Y - ")
|
||||
endstr = end_date.strftime("%B %d, %Y")
|
||||
end
|
||||
|
||||
result = startstr + endstr
|
||||
result
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if the user is registered to the conference
|
||||
#
|
||||
# ====Args
|
||||
# * +user+ -> The user we check for
|
||||
# ====Returns
|
||||
# * +nil+ -> If the user doesn't exist
|
||||
# * +false+ -> If the user is registered
|
||||
# * +true+ - If the user isn't registered
|
||||
def user_registered? user
|
||||
return nil if user.nil?
|
||||
return nil if user.person.nil?
|
||||
|
||||
if self.registrations.where(:person_id => user.person.id).count == 0
|
||||
Rails.logger.debug("Returning false")
|
||||
false
|
||||
logger.debug("User #{user.email} isn't registered to self.title")
|
||||
return false
|
||||
else
|
||||
Rails.logger.debug("Returning true")
|
||||
true
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if the registration for the conference is currently open
|
||||
#
|
||||
# ====Returns
|
||||
# * +false+ -> If the conference dates are not set or today isn't in the
|
||||
# registration period.
|
||||
# * +true+ -> If today is in the registration period.
|
||||
def registration_open?
|
||||
today = Date.current
|
||||
if self.registration_start_date.nil? || self.registration_end_date.nil?
|
||||
|
|
@ -105,6 +101,12 @@ class Conference < ActiveRecord::Base
|
|||
(registration_start_date..registration_end_date).cover?(today)
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if the call for papers for the conference is currently open
|
||||
#
|
||||
# ====Returns
|
||||
# * +false+ -> If the CFP is not set or today isn't in the CFP period.
|
||||
# * +true+ -> If today is in the CFP period.
|
||||
def cfp_open?
|
||||
today = Date.current
|
||||
cfp = self.call_for_papers
|
||||
|
|
@ -114,17 +116,28 @@ class Conference < ActiveRecord::Base
|
|||
|
||||
return false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
# Creates a venue and sets self.venue_id to it's id. Used as before_create.
|
||||
#
|
||||
def create_venue
|
||||
self.venue_id = Venue.create.id
|
||||
true
|
||||
end
|
||||
|
||||
##
|
||||
# Creates a EmailSettings association proxy. Used as before_create.
|
||||
#
|
||||
def create_email_settings
|
||||
build_email_settings
|
||||
true
|
||||
end
|
||||
|
||||
##
|
||||
# Creates a UID for the conference. Used as before_create.
|
||||
#
|
||||
def generate_guid
|
||||
begin
|
||||
guid = SecureRandom.urlsafe_base64
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
= conference.title
|
||||
%small
|
||||
%b
|
||||
= conference.date_range_string
|
||||
= conference_date_string(conference)
|
||||
- if conference.venue.name and conference.venue.website and conference.venue.address
|
||||
%p
|
||||
%small
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue