<commit_before>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, :media_id, :media_type, :require_registration, :difficulty_level_id

  acts_as_commentable

  has_many :event_people, :dependent => :destroy
  has_many :event_attachments, :dependent => :destroy
  has_many :people, :through => :event_people
  has_many :speakers, :through => :event_people, :source => :person, :conditions => {"event_people.event_role" => "speaker"}
  has_many :votes
  has_many :voters, :through => :votes, :source => :person
  belongs_to :event_type

  has_and_belongs_to_many :registrations

  belongs_to :track
  belongs_to :room
  belongs_to :difficulty_level
  belongs_to :conference

  accepts_nested_attributes_for :event_people, :allow_destroy => true
  accepts_nested_attributes_for :event_attachments, :allow_destroy => true, :reject_if => :all_blank
  accepts_nested_attributes_for :people
  before_create :generate_guid

  def self.media_types
    media_types = {:youtube => 'YouTube', :slideshare => 'SlideShare',  :flickr => 'Flickr', :vimeo => 'Vimeo', :speakerdeck => 'Speakerdeck', :instagram => 'Instagram'}
    return media_types
  end

  validate :abstract_limit
  validate :biography_exists
  validates :title, :presence => true
  validates :abstract, :presence => true
  validates :media_type, inclusion: {in: self.media_types.values}

  scope :confirmed, where(:state => "confirmed")

  state_machine :initial => :new do
    state :new<commit_msg>Adds allow_nil for media_type validation for backward compatibility<commit_after>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, :media_id, :media_type, :require_registration, :difficulty_level_id

  acts_as_commentable

  has_many :event_people, :dependent => :destroy
  has_many :event_attachments, :dependent => :destroy
  has_many :people, :through => :event_people
  has_many :speakers, :through => :event_people, :source => :person, :conditions => {"event_people.event_role" => "speaker"}
  has_many :votes
  has_many :voters, :through => :votes, :source => :person
  belongs_to :event_type

  has_and_belongs_to_many :registrations

  belongs_to :track
  belongs_to :room
  belongs_to :difficulty_level
  belongs_to :conference

  accepts_nested_attributes_for :event_people, :allow_destroy => true
  accepts_nested_attributes_for :event_attachments, :allow_destroy => true, :reject_if => :all_blank
  accepts_nested_attributes_for :people
  before_create :generate_guid

  def self.media_types
    media_types = {:youtube => 'YouTube', :slideshare => 'SlideShare',  :flickr => 'Flickr', :vimeo => 'Vimeo', :speakerdeck => 'Speakerdeck', :instagram => 'Instagram'}
    return media_types
  end

  validate :abstract_limit
  validate :biography_exists
  validates :title, :presence => true
  validates :abstract, :presence => true
  validates :media_type, :allow_nil => true, inclusion: {in: self.media_types.values}

  scope :confirmed, where(:state => "confirmed")

  state_machine :initial => :new do
    state :new
{'fraction_non_alphanumeric': 0.11044776119402985, 'fraction_numerical': 0.0, 'mean_word_length': 6.17558886509636, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7177636', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1075, 'n_words': 250}