Refactoring Conference/Event media to new media object

close #420
This commit is contained in:
Chrisbr 2014-08-05 18:23:42 +02:00
parent 850beb72e1
commit 2a731e8350
31 changed files with 491 additions and 57 deletions

9
app/models/commercial.rb Normal file
View file

@ -0,0 +1,9 @@
class Commercial < ActiveRecord::Base
belongs_to :commercialable, polymorphic: true
attr_accessible :commercial_id, :commercial_type
validates :commercial_id, :commercial_type, presence: true
validates :commercial_type, inclusion: { in: CONFIG['commercial_types'].values }, allow_blank: true
end

View file

@ -12,7 +12,7 @@ class Conference < ActiveRecord::Base
:registration_start_date, :registration_end_date, :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, :media_id, :media_type, :color,
:vpositions_attributes, :use_volunteers, :color,
:description, :registration_description, :ticket_description,
:sponsorship_levels_attributes, :sponsors_attributes,
:sponsor_description, :sponsor_email, :lodging_description,
@ -48,6 +48,7 @@ class Conference < ActiveRecord::Base
has_many :photos, dependent: :destroy
has_many :targets, dependent: :destroy
has_many :campaigns, dependent: :destroy
has_many :commercials, as: :commercialable, dependent: :destroy
belongs_to :venue
accepts_nested_attributes_for :rooms, reject_if: proc { |r| r['name'].blank? }, allow_destroy: true
@ -94,12 +95,6 @@ class Conference < ActiveRecord::Base
before_create :create_email_settings
before_create :add_color
def self.media_types
media_types = { youtube: 'YouTube', slideshare: 'SlideShare', flickr: 'Flickr', vimeo: 'Vimeo',
speakerdeck: 'Speakerdeck', instagram: 'Instagram' }
return media_types
end
##
# Checks if the user is registered to the conference
#

View file

@ -2,7 +2,7 @@ class Event < ActiveRecord::Base
include ActiveRecord::Transitions
has_paper_trail
attr_accessible :title, :subtitle, :abstract, :description, :event_type_id, :users_attributes,
:user, :proposal_additional_speakers, :track_id, :media_id, :media_type,
:user, :proposal_additional_speakers, :track_id,
:require_registration, :difficulty_level_id
acts_as_commentable
@ -15,6 +15,7 @@ class Event < ActiveRecord::Base
has_many :speakers, through: :event_users, source: :user
has_many :votes
has_many :voters, through: :votes, source: :user
has_many :commercials, as: :commercialable, dependent: :destroy
belongs_to :event_type
has_and_belongs_to_many :registrations
@ -36,7 +37,6 @@ class Event < ActiveRecord::Base
validates :abstract, presence: true
validates :event_type, presence: true
validates :conference, presence: true
validates :media_type, inclusion: { in: Conference.media_types.values }, allow_blank: true
scope :confirmed, -> { where(state: 'confirmed') }