created_by and updated_by logic for contact#info

This commit is contained in:
Andres Keskküla 2014-08-05 15:23:55 +03:00
parent 3dca771bcb
commit 902cb8d441
7 changed files with 66 additions and 6 deletions

View file

@ -6,6 +6,9 @@ class Contact < ActiveRecord::Base
has_many :domain_contacts
has_many :domains, through: :domain_contacts
belongs_to :created_by, class_name: 'EppUser', foreign_key: :created_by_id
belongs_to :updated_by, class_name: 'EppUser', foreign_key: :updated_by_id
validates_presence_of :code, :name, :phone, :email, :ident
validate :ident_must_be_valid
@ -39,6 +42,14 @@ class Contact < ActiveRecord::Base
ident_type != IDENT_TYPE_ICO
end
def crID
created_by ? created_by.username : nil
end
def upID
updated_by ? updated_by.username : nil
end
class << self
def check_availability(codes)
codes = [codes] if codes.is_a?(String)

View file

@ -1,4 +1,5 @@
class EppUser < ActiveRecord::Base
#TODO should have max request limit per day
belongs_to :registrar
has_many :contacts
end