<commit_before># +editor+ would like to become an editor for +person+. Sent in an email with link keyed by +token+.
# Sends email with link after_create. See EditorRequestMailer.
class EditorRequest < ActiveRecord::Base
  belongs_to :editor, :class_name => "Person"
  belongs_to :person
  
  validates_presence_of :editor
  validates_presence_of :email
  validates_presence_of :expires_at
  validates_presence_of :person
  validates_presence_of :token
  
  before_save :destroy_duplicates
  
  # Set to expire in 1 week. Auto-set token.
  def before_validation
    self.email = person.try(:email)
    self.expires_at = 1.week.from_now
    self.token = Auth<PASSWORD>::Random.friendly_token
  end
  
  def destroy_duplicates
    EditorRequest.destroy_all :person_id => person_id, :editor_id => editor_id
  end
  
  # Send email
  def after_create
    EditorRequestMailer.deliver_request(self)
  end
  
  # Make +editor+ an editor of +person+
  def grant!
    unless person.editors.include?(editor)<commit_msg>Add expired scope to EditroRequests<commit_after># +editor+ would like to become an editor for +person+. Sent in an email with link keyed by +token+.
# Sends email with link after_create. See EditorRequestMailer.
class EditorRequest < ActiveRecord::Base
  belongs_to :editor, :class_name => "Person"
  belongs_to :person
  
  validates_presence_of :editor
  validates_presence_of :email
  validates_presence_of :expires_at
  validates_presence_of :person
  validates_presence_of :token
  
  before_save :destroy_duplicates
  
  named_scope :expired, lambda { { :conditions => [ "expires_at <= ?", ASSOCIATION.now ] } }
  
  # Set to expire in 1 week. Auto-set token.
  def before_validation
    self.email = person.try(:email)
    self.expires_at = 1.week.from_now
    self.token = Auth<PASSWORD>::Random.friendly_token
  end
  
  def destroy_duplicates
    EditorRequest.destroy_all :person_id => person_id, :editor_id => editor_id
  end
  
  # Send email
  def after_create
    EditorRequestMailer.deliver_request(self)
  end
  
  # Make +editor+ an editor of +person+
  def grant!
    unless person.editors.include?(editor)
{'fraction_non_alphanumeric': 0.07966260543580131, 'fraction_numerical': 0.0018744142455482662, 'mean_word_length': 4.157004830917875, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, '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': '7220578', 'n_tokens_mistral': 707, 'n_tokens_neox': 699, 'n_words': 185}