mirror of
https://github.com/internetee/registry.git
synced 2025-07-13 14:35:05 +02:00
Contact - Registrar relation
This commit is contained in:
parent
9519538744
commit
3d652bf85b
11 changed files with 90 additions and 16 deletions
|
@ -13,12 +13,14 @@ class Contact < ActiveRecord::Base
|
|||
has_many :domain_contacts
|
||||
has_many :domains, through: :domain_contacts
|
||||
|
||||
# TODO remove the x_by
|
||||
belongs_to :created_by, class_name: 'EppUser', foreign_key: :created_by_id
|
||||
belongs_to :updated_by, class_name: 'EppUser', foreign_key: :updated_by_id
|
||||
belongs_to :registrar
|
||||
|
||||
accepts_nested_attributes_for :address, :disclosure
|
||||
|
||||
validates :code, :phone, :email, :ident, :address, presence: true
|
||||
validates :code, :phone, :email, :ident, :address, :registrar,presence: true
|
||||
|
||||
validate :ident_must_be_valid
|
||||
#validate :presence_of_one_address
|
||||
|
@ -33,6 +35,8 @@ class Contact < ActiveRecord::Base
|
|||
delegate :street, to: :address#, prefix: true
|
||||
delegate :zip, to: :address#, prefix: true
|
||||
|
||||
#scopes
|
||||
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
||||
# archiving
|
||||
has_paper_trail class_name: 'ContactVersion'
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ class Registrar < ActiveRecord::Base
|
|||
has_many :ns_sets
|
||||
has_many :epp_users
|
||||
has_many :users
|
||||
has_many :contacts
|
||||
|
||||
validates :name, :reg_no, :address, :country, presence: true
|
||||
validates :name, :reg_no, uniqueness: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue