<commit_before>class Organization < ActiveRecord::Base
  belongs_to :member
  
  mount_uploader :logo, ImageObjectUploader
  
  attr_accessible :name, :description, :url, :logo, :logo_cache, :remote,
                  :cached_contact_name, :cached_contact_phone, :cached_contact_email,
                  :cached_twitter, :cached_linkedin, :cached_facebook
  
  attr_writer     :remote
  
  # Using after_save here so we get the right image urls
  after_save :send_to_capsule
  skip_callback :save, :after, :send_to_capsule, :if => lambda { self.remote === true }
  
  validates :name, :presence => true, :on => :update
  validates :name, :uniqueness => true
  validates :description, :presence => true, :on => :update
  validates :description, :length => { :maximum  => 500, :too_long => "Your description cannot be longer than %{count} characters"}, :if => :supporter?
  validates :description, :length => { :maximum  => 1000, :too_long => "Your description cannot be longer than %{count} characters"}, :if => :member?

  # We use both a URL-parsing validator, and a simple regexp here
  # so that we exclude things like http://localhost, which are valid
  # but undesirable
  validates :url, :url => {:allow_nil => true}, :format => {:with => /^https?:\/\/([^\.\/]+?)\.([^\.\/]+?)/, :allow_nil => true}
  
  def remote
    @remote || false
  end

  def member?
    self.member.product_name == "member"
  end

  def supporter?
    self.member.product_name == "supporter"
  end
  
  def character_limit
    supporter? ? 500 : 1000 
  end
    
  def send_to_capsule
    if valid?
      organization = {
        :name => name
      }
  
      directory_entry = {
        :description => description,
        :homepage => url,
        :logo => logo.url,
        :thumbnail => logo.square.url
      }
  
      date = updated_at.to_s
    
      Resque.enqueue(SendDirectoryEntryToCapsule, organization, directory_entry, date)
    end
  end
end<commit_msg>Store new contact details in directory entry<commit_after>class Organization < ActiveRecord::Base
  belongs_to :member
  
  mount_uploader :logo, ImageObjectUploader
  
  attr_accessible :name, :description, :url, :logo, :logo_cache, :remote,
                  :cached_contact_name, :cached_contact_phone, :cached_contact_email,
                  :cached_twitter, :cached_linkedin, :cached_facebook
  
  attr_writer     :remote
  
  # Using after_save here so we get the right image urls
  after_save :send_to_capsule
  skip_callback :save, :after, :send_to_capsule, :if => lambda { self.remote === true }
  
  validates :name, :presence => true, :on => :update
  validates :name, :uniqueness => true
  validates :description, :presence => true, :on => :update
  validates :description, :length => { :maximum  => 500, :too_long => "Your description cannot be longer than %{count} characters"}, :if => :supporter?
  validates :description, :length => { :maximum  => 1000, :too_long => "Your description cannot be longer than %{count} characters"}, :if => :member?

  # We use both a URL-parsing validator, and a simple regexp here
  # so that we exclude things like http://localhost, which are valid
  # but undesirable
  validates :url, :url => {:allow_nil => true}, :format => {:with => /^https?:\/\/([^\.\/]+?)\.([^\.\/]+?)/, :allow_nil => true}
  
  def remote
    @remote || false
  end

  def member?
    self.member.product_name == "member"
  end

  def supporter?
    self.member.product_name == "supporter"
  end
  
  def character_limit
    supporter? ? 500 : 1000 
  end
    
  def send_to_capsule
    if valid?
      organization = {
        :name => name
      }
  
      directory_entry = {
        :description => description,
        :homepage    => url,
        :logo        => logo.url,
        :thumbnail   => logo.square.url,
        :contact     => cached_contact_name,
        :phone       => cached_contact_phone,
        :email       => cached_contact_email,
        :twitter     => cached_twitter,
        :linkedin    => cached_linkedin,
        :facebook    => cached_facebook,
      }
  
      date = updated_at.to_s
    
      Resque.enqueue(SendDirectoryEntryToCapsule, organization, directory_entry, date)
    end
  end
end
{'fraction_non_alphanumeric': 0.12300737568403522, 'fraction_numerical': 0.006661908160837497, 'mean_word_length': 2.932647333956969, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, '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': '3484665', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1284, 'n_words': 361}