mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
0a2ed60b9e
11 changed files with 50 additions and 46 deletions
|
@ -10,7 +10,8 @@ class Address < ActiveRecord::Base
|
|||
belongs_to :contact
|
||||
belongs_to :country
|
||||
|
||||
#validates_inclusion_of :type, in: TYPES
|
||||
# TODO: validate inclusion of :type in LONG_TYPES or smth similar
|
||||
# validates_inclusion_of :type, in: TYPES
|
||||
|
||||
class << self
|
||||
def extract_attributes(ah)
|
||||
|
@ -31,8 +32,7 @@ class Address < ActiveRecord::Base
|
|||
|
||||
def addr_hash_from_params(addr)
|
||||
return {} unless addr[:addr].is_a?(Hash)
|
||||
{
|
||||
name: addr[:name],
|
||||
{ name: addr[:name],
|
||||
org_name: addr[:org],
|
||||
country_id: Country.find_by(iso: addr[:addr][:cc]).try(:id),
|
||||
city: addr[:addr][:city],
|
||||
|
@ -40,7 +40,7 @@ class Address < ActiveRecord::Base
|
|||
street2: addr[:addr][:street][1],
|
||||
street3: addr[:addr][:street][2],
|
||||
zip: addr[:addr][:pc]
|
||||
}.delete_if { |k, v| v.nil? }
|
||||
}.delete_if { |_k, v| v.nil? }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
class Contact < ActiveRecord::Base
|
||||
# TODO Foreign contact will get email with activation link/username/temp password
|
||||
# TODO Phone number validation, in first phase very minimam in order to support current registries
|
||||
# TODO: Foreign contact will get email with activation link/username/temp password
|
||||
# TODO: Phone number validation, in first phase very minimam in order to support current registries
|
||||
|
||||
include EppErrors
|
||||
|
||||
EPP_ATTR_MAP = {}
|
||||
|
||||
has_one :local_address#, class_name: 'Address'#, foreign_key: 'local_address_id'
|
||||
has_one :local_address
|
||||
has_one :international_address
|
||||
|
||||
has_many :domain_contacts
|
||||
|
@ -17,14 +17,18 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
accepts_nested_attributes_for :local_address, :international_address
|
||||
|
||||
validates_presence_of :code, :phone, :email, :ident
|
||||
# validates_presence_of :code, :phone, :email, :ident
|
||||
validates :code, :phone, :email, :ident, presence: true
|
||||
|
||||
validate :ident_must_be_valid
|
||||
|
||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/
|
||||
validates :email, format: /@/
|
||||
|
||||
validates_uniqueness_of :code, message: :epp_id_taken
|
||||
# validates_uniqueness_of :code, message: :epp_id_taken
|
||||
validates :code, uniqueness: { message: :epp_id_taken }
|
||||
|
||||
delegate :name, to: :international_address
|
||||
|
||||
IDENT_TYPE_ICO = 'ico'
|
||||
IDENT_TYPES = [
|
||||
|
@ -38,18 +42,14 @@ class Contact < ActiveRecord::Base
|
|||
CONTACT_TYPE_ADMIN = 'admin'
|
||||
CONTACT_TYPES = [CONTACT_TYPE_TECH, CONTACT_TYPE_ADMIN]
|
||||
|
||||
#TEMP METHODS for transaction to STI
|
||||
def name
|
||||
international_address.name
|
||||
end
|
||||
|
||||
# TEMP METHOD for transaction to STI
|
||||
def address
|
||||
international_address
|
||||
end
|
||||
##
|
||||
|
||||
|
||||
def ident_must_be_valid
|
||||
# TODO Ident can also be passport number or company registry code.
|
||||
# TODO: Ident can also be passport number or company registry code.
|
||||
# so have to make changes to validations (and doc/schema) accordingly
|
||||
return true unless ident.present? && ident_type.present? && ident_type == 'op'
|
||||
code = Isikukood.new(ident)
|
||||
|
@ -64,11 +64,11 @@ class Contact < ActiveRecord::Base
|
|||
ident_type != IDENT_TYPE_ICO
|
||||
end
|
||||
|
||||
def crID
|
||||
def cr_id
|
||||
created_by ? created_by.username : nil
|
||||
end
|
||||
|
||||
def upID
|
||||
def up_id
|
||||
updated_by ? updated_by.username : nil
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
class InternationalAddress < Address
|
||||
|
||||
end
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
class LocalAddress < Address
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue