Merge branch 'master' of github.com:internetee/registry

This commit is contained in:
Martin Lensment 2014-08-26 13:52:52 +03:00
commit 0a2ed60b9e
11 changed files with 50 additions and 46 deletions

View file

@ -11,5 +11,5 @@ module Shared::UserStamper
end
true
end
end
end

View file

@ -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

View file

@ -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

View file

@ -1,3 +1,2 @@
class InternationalAddress < Address
end

View file

@ -1,3 +1,2 @@
class LocalAddress < Address
end

View file

@ -11,9 +11,9 @@ xml.epp_head do
xml.tag!('contact:fax', @contact.fax)
xml.tag!('contact:email', @contact.email)
xml.tag!('contact:clID', @current_epp_user.username) if @current_epp_user
xml.tag!('contact:crID', @contact.crID ) if @contact.crID
xml.tag!('contact:crID', @contact.cr_id ) if @contact.cr_id
xml.tag!('contact:crDate', @contact.created_at)
xml.tag!('contact:upID', @contact.upID) if @contact.upID
xml.tag!('contact:upID', @contact.up_id) if @contact.up_id
xml.tag!('contact:upDate', @contact.updated_at) unless @contact.updated_at == @contact.created_at
xml.tag!('contact:trDate', '123') if false
xml.tag!('contact:authInfo', '123') if false