<commit_before>module SemiStatic
  class Contact < ActiveRecord::Base
    attr_accessible :surname, :message, :email, :telephone, :name, :locale, :agreement_ids

    has_and_belongs_to_many :agreements, :join_table => :semi_static_agreements_contacts
  
    # TODO: The load order of the locales files stops us adding the correct message for this, its
    # needs to say 'Please provide either an email or telephone number'
    # validates_presence_of :telephone, :unless => :email?
    validates_format_of :email, :with => /.+@.+\..+/i, :allow_blank => true, :allow_nil => true
    validates_presence_of :email, :unless => :telephone?
  
    after_create :send_email
    after_create :check_subscription
  
    def check_subscription
      unless self.email.blank? || self.agreements.subscriber.blank?
        if (s = SemiStatic::Subscriber.find_by_email(self.email)).blank?
          s = SemiStatic::Subscriber.create(:surname => surname, :name => name, :email => email, :telephone => telephone, :locale => locale)
        else
          attributes.each{|k,v| attributes.delete(k) if read_attribute(k).blank?}
          s.update_attributes(:name => s.name, :surname => s.surname, :telephone  => s.telephone, :locale => s.locale)
        end
        s.category = SemiStatic::SubscriberCategory.find_by_name('website')
        s.save
      end
    end

    def fullname
      name + ' ' + surname
    end
  
    def send_email
      SemiStatic::ContactMailer.contact_notification(self).deliver
    end
  end
end<commit_msg>Bug fix for fullname<commit_after>module SemiStatic
  class Contact < ActiveRecord::Base
    attr_accessible :surname, :message, :email, :telephone, :name, :locale, :agreement_ids

    has_and_belongs_to_many :agreements, :join_table => :semi_static_agreements_contacts
  
    # TODO: The load order of the locales files stops us adding the correct message for this, its
    # needs to say 'Please provide either an email or telephone number'
    # validates_presence_of :telephone, :unless => :email?
    validates_format_of :email, :with => /.+@.+\..+/i, :allow_blank => true, :allow_nil => true
    validates_presence_of :email, :unless => :telephone?
  
    after_create :send_email
    after_create :check_subscription
  
    def check_subscription
      unless self.email.blank? || self.agreements.subscriber.blank?
        if (s = SemiStatic::Subscriber.find_by_email(self.email)).blank?
          s = SemiStatic::Subscriber.create(:surname => surname, :name => name, :email => email, :telephone => telephone, :locale => locale)
        else
          attributes.each{|k,v| attributes.delete(k) if read_attribute(k).blank?}
          s.update_attributes(:name => s.name, :surname => s.surname, :telephone  => s.telephone, :locale => s.locale)
        end
        s.category = SemiStatic::SubscriberCategory.find_by_name('website')
        s.save
      end
    end

    def fullname
      [name, surname].join(' ')
    end
  
    def send_email
      SemiStatic::ContactMailer.contact_notification(self).deliver
    end
  end
end
{'fraction_non_alphanumeric': 0.11379986919555266, 'fraction_numerical': 0.0, 'mean_word_length': 3.4591836734693877, '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': '5428772', 'n_tokens_mistral': 976, 'n_tokens_neox': 932, 'n_words': 230}