<commit_before># An Account on DocumentCloud can be used to access the workspace and upload
# documents. Accounts have full priviledges for the entire organization, at the
# moment.

class Account < ActiveRecord::Base
  include DC::Access
  include DC::Roles

  # Associations:
  has_many :memberships
  has_many :organizations,   :through => :memberships
  has_many :projects,        :dependent => :destroy
  has_many :annotations
  has_many :collaborations,  :dependent => :destroy
  has_many :processing_jobs, :dependent => :destroy
  has_one  :security_key,    :dependent => :destroy, :as => :securable
  has_many :shared_projects, :through => :collaborations, :source => :project


  # Validations:
  validates  :first_name, :last_name, :presence=>true
  validates  :email,
    :presence   =>true,
    :uniqueness =>{ :case_sensitive => false },
    :format     =>{ :with => DC::Validators::EMAIL },
    :if         => :has_memberships?

  validate   :validate_identity_is_unique<commit_msg>Add a has_many documents for easier querying<commit_after># An Account on DocumentCloud can be used to access the workspace and upload
# documents. Accounts have full priviledges for the entire organization, at the
# moment.

class Account < ActiveRecord::Base
  include DC::Access
  include DC::Roles

  # Associations:
  has_many :memberships
  has_many :organizations,   :through => :memberships
  has_many :projects,        :dependent => :destroy
  has_many :annotations
  has_many :collaborations,  :dependent => :destroy
  has_many :processing_jobs, :dependent => :destroy
  has_one  :security_key,    :dependent => :destroy, :as => :securable
  has_many :shared_projects, :through => :collaborations, :source => :project
  has_many :documents

  # Validations:
  validates  :first_name, :last_name, :presence=>true
  validates  :email,
    :presence   =>true,
    :uniqueness =>{ :case_sensitive => false },
    :format     =>{ :with => DC::Validators::EMAIL },
    :if         => :has_memberships?

  validate   :validate_identity_is_unique
{'fraction_non_alphanumeric': 0.10714285714285714, 'fraction_numerical': 0.0, 'mean_word_length': 4.270618556701031, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '7209071', 'n_tokens_mistral': 629, 'n_tokens_neox': 608, 'n_words': 177}