Add difficulty levels

This commit is contained in:
Stella 2014-02-23 16:09:09 +02:00
parent 4356616566
commit 5b35e25ecd
15 changed files with 119 additions and 3 deletions

View file

@ -2,7 +2,7 @@ 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,
:use_dietary_choices, :use_supporter_levels, :supporter_levels_attributes, :social_events_attributes,
:event_types_attributes, :registration_start_date, :registration_end_date, :logo
:event_types_attributes, :difficulty_levels_attributes, :use_difficulty_levels, :registration_start_date, :registration_end_date, :logo
has_paper_trail
@ -15,6 +15,7 @@ class Conference < ActiveRecord::Base
has_many :events, :dependent => :destroy
has_many :event_types, :dependent => :destroy
has_many :tracks, :dependent => :destroy
has_many :difficulty_levels, :dependent => :destroy
has_many :rooms, :dependent => :destroy
has_many :registrations, :dependent => :destroy
@ -22,6 +23,7 @@ class Conference < ActiveRecord::Base
accepts_nested_attributes_for :rooms, :reject_if => proc {|r| r["name"].blank?}, :allow_destroy => true
accepts_nested_attributes_for :tracks, :reject_if => proc {|r| r["name"].blank?}, :allow_destroy => true
accepts_nested_attributes_for :difficulty_levels, :allow_destroy => true
accepts_nested_attributes_for :social_events, :allow_destroy => true
accepts_nested_attributes_for :venue
accepts_nested_attributes_for :dietary_choices, :allow_destroy => true
@ -41,6 +43,7 @@ class Conference < ActiveRecord::Base
:social_tag
validates_uniqueness_of :short_title
validates_format_of :short_title, :with => /^[a-zA-Z0-9_-]*$/
before_create :generate_guid
before_create :create_venue
before_create :create_email_settings

View file

@ -0,0 +1,8 @@
class DifficultyLevel < ActiveRecord::Base
attr_accessible :title, :description, :color
belongs_to :conference
has_many :events
validates :title, :presence => true
end

View file

@ -1,8 +1,8 @@
class Event < ActiveRecord::Base
include ActiveRecord::Transitions
has_paper_trail
attr_accessible :title, :subtitle, :abstract, :description, :event_type_id, :people_attributes, :person,
:proposal_additional_speakers, :track_id, :video_id, :video_type, :require_registration
attr_accessible :title, :subtitle, :abstract, :description, :event_type_id, :people_attributes, :person, :proposal_additional_speakers, :track_id, :video_id, :video_type, :require_registration, :difficulty_level_id
acts_as_commentable
has_many :event_people, :dependent => :destroy
@ -17,6 +17,7 @@ class Event < ActiveRecord::Base
belongs_to :track
belongs_to :room
belongs_to :difficulty_level
belongs_to :conference
accepts_nested_attributes_for :event_people, :allow_destroy => true
@ -92,6 +93,7 @@ class Event < ActiveRecord::Base
person
end
end
def as_json(options)
json = super(options)
@ -106,6 +108,7 @@ class Event < ActiveRecord::Base
else
json[:track_color] = self.track.color;
end
if self.event_type.nil?
json[:length] = 25
else
@ -114,6 +117,7 @@ class Event < ActiveRecord::Base
json
end
def transition_possible?(transition)
self.class.state_machine.events_for(self.current_state).include?(transition)
end
@ -125,6 +129,7 @@ class Event < ActiveRecord::Base
end
end
end
def process_acceptance(options)
if options[:send_mail] == "true"
Rails.logger.debug "Sending acceptance mail"
@ -156,6 +161,7 @@ class Event < ActiveRecord::Base
end
public_state
end
def abstract_word_count
if self.abstract.nil?
0
@ -163,6 +169,7 @@ class Event < ActiveRecord::Base
self.abstract.split.size
end
end
private
def abstract_limit
@ -184,6 +191,7 @@ class Event < ActiveRecord::Base
errors.add(:person_biography, "must be filled out")
end
end
def generate_guid
begin
guid = SecureRandom.urlsafe_base64