<commit_before>class Profile < ActiveRecord::Base
  CONFLICT_AREAS = ['BI', 'RW', 'ZA']

  DIETARY_LAW_OPTIONS = [
    ['No preference', 0],
    ['Halal', 1],
    ['Kosher', 2],
    ['Vegetarian', 3]
  ]

  attr_accessible :address, :calling_code, :citizenship_id, :city, :country_id, 
    :date_of_birth, :field_of_study, :gender, :gender_specify, :nationality, 
    :phone, :postal_code, :school, :motivation_essay, :next_of_kin_name,
    :next_of_kin_phone, :next_of_kin_address, :next_of_kin_relation, :dietary_law, 
    :other_diet_preferences, :allergy_animals, :allergy_gluten, :allergy_lactose, 
    :allergy_nuts, :other_allergies, :host_gender_preference, :smoke, :handicap, 
    :other_host_preferences

  belongs_to :citizenship, class_name: 'Country'
  belongs_to :country
  belongs_to :user

  # Validation for core profile fields
  validates :date_of_birth,   presence: true
  validates :gender,          presence: true
  validates :nationality,     presence: true
  validates :citizenship_id,  presence: true

  validates :school,          presence: true
  validates :field_of_study,  presence: true

  validates :address,       presence: true
  validates :postal_code,   presence: true
  validates :city,          presence: true
  validates :country_id,    presence: true
  validates :calling_code,  presence: true
  validates :phone,         presence: true, numericality: true

  validates :motivation_essay, presence: true, on: :update

  # Validations for next of kin information
  with_options if: "user.is_participant?" do |p|
    p.validates :next_of_kin_name,      presence: true
    p.validates :next_of_kin_phone,     presence: true
    p.validates :next_of_kin_address,   presence: true
    p.validates :next_of_kin_relation,  presence: true
  end
  
  before_validation :strip_phone_formating_characters

  def related_to_conflict_area?
    citizenship_in_conflict_area? || lives_in_conflict_area?
  end

  def citizenship_in_conflict_area?
    CONFLICT_AREAS.any? { |code| code.eql?(citizenship.code) }
  end

  def lives_in_conflict_area?
    CONFLICT_AREAS.any? { |code| code.eql?(country.code) }
  end<commit_msg>Removes requirement for motivation essay, next year, put that shit in application<commit_after>class Profile < ActiveRecord::Base
  CONFLICT_AREAS = ['BI', 'RW', 'ZA']

  DIETARY_LAW_OPTIONS = [
    ['No preference', 0],
    ['Halal', 1],
    ['Kosher', 2],
    ['Vegetarian', 3]
  ]

  attr_accessible :address, :calling_code, :citizenship_id, :city, :country_id, 
    :date_of_birth, :field_of_study, :gender, :gender_specify, :nationality, 
    :phone, :postal_code, :school, :motivation_essay, :next_of_kin_name,
    :next_of_kin_phone, :next_of_kin_address, :next_of_kin_relation, :dietary_law, 
    :other_diet_preferences, :allergy_animals, :allergy_gluten, :allergy_lactose, 
    :allergy_nuts, :other_allergies, :host_gender_preference, :smoke, :handicap, 
    :other_host_preferences

  belongs_to :citizenship, class_name: 'Country'
  belongs_to :country
  belongs_to :user

  # Validation for core profile fields
  validates :date_of_birth,   presence: true
  validates :gender,          presence: true
  validates :nationality,     presence: true
  validates :citizenship_id,  presence: true

  validates :school,          presence: true
  validates :field_of_study,  presence: true

  validates :address,       presence: true
  validates :postal_code,   presence: true
  validates :city,          presence: true
  validates :country_id,    presence: true
  validates :calling_code,  presence: true
  validates :phone,         presence: true, numericality: true

  # Validations for next of kin information
  with_options if: "user.is_participant?" do |p|
    p.validates :next_of_kin_name,      presence: true
    p.validates :next_of_kin_phone,     presence: true
    p.validates :next_of_kin_address,   presence: true
    p.validates :next_of_kin_relation,  presence: true
  end
  
  before_validation :strip_phone_formating_characters

  def related_to_conflict_area?
    citizenship_in_conflict_area? || lives_in_conflict_area?
  end

  def citizenship_in_conflict_area?
    CONFLICT_AREAS.any? { |code| code.eql?(citizenship.code) }
  end

  def lives_in_conflict_area?
    CONFLICT_AREAS.any? { |code| code.eql?(country.code) }
  end
{'fraction_non_alphanumeric': 0.0949278734295021, 'fraction_numerical': 0.0018613308515588647, 'mean_word_length': 4.3403726708074535, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5408981', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1517, 'n_words': 330}