mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 00:33:36 +02:00
Merge branch 'contact_ident'
Conflicts: db/schema.rb
This commit is contained in:
commit
8a4b91c3b7
8 changed files with 45 additions and 6 deletions
|
@ -12,6 +12,7 @@ module Epp::ContactsHelper
|
|||
)
|
||||
end
|
||||
@contact.name = ph[:postalInfo][:name]
|
||||
@contact.ident_type = ident_type
|
||||
|
||||
@contact.addresses << Address.new(
|
||||
country_id: Country.find_by(iso: ph[:postalInfo][:cc]),
|
||||
|
@ -53,4 +54,16 @@ module Epp::ContactsHelper
|
|||
render 'epp/error'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ident_type
|
||||
result = params[:frame].slice(/(?<=\<ns2:ident type=)(.*)(?=<)/)
|
||||
|
||||
return nil unless result
|
||||
|
||||
Contact::IDENT_TYPES.any? { |type| return type if result.include?(type) }
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -7,10 +7,17 @@ class Contact < ActiveRecord::Base
|
|||
validate :ident_must_be_valid
|
||||
validates :phone, format: { with: /\+\d{3}\.\d+/, message: "bad format" }
|
||||
|
||||
IDENT_TYPES = [
|
||||
"ico", #Company registry code (or similar)
|
||||
"op", #Estonian ID
|
||||
"passport", #Passport number
|
||||
"birthday" #Birthday date
|
||||
]
|
||||
|
||||
def ident_must_be_valid
|
||||
#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?
|
||||
return true unless ident.present? && ident_type.present? && ident_type == "op"
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, 'bad format') unless code.valid?
|
||||
end
|
||||
|
|
5
db/migrate/20140730082532_add_ident_type_to_contact.rb
Normal file
5
db/migrate/20140730082532_add_ident_type_to_contact.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddIdentTypeToContact < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :contacts, :ident_type, :string
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140730082358) do
|
||||
ActiveRecord::Schema.define(version: 20140730082532) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -37,6 +37,7 @@ ActiveRecord::Schema.define(version: 20140730082358) do
|
|||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "ident"
|
||||
t.string "ident_type"
|
||||
end
|
||||
|
||||
create_table "countries", force: true do |t|
|
||||
|
|
|
@ -72,9 +72,20 @@
|
|||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="identType">
|
||||
<restriction base="normalizedString">
|
||||
<maxLength value="11"/>
|
||||
<complexType name="identType">
|
||||
<simpleContent>
|
||||
<extension base="eppcom:clIDType">
|
||||
<attribute name="type" type="contact:identAttrType"/>
|
||||
</extension>
|
||||
</simpleContent>
|
||||
</complexType>
|
||||
|
||||
<simpleType name="identAttrType">
|
||||
<restriction base="token">
|
||||
<enumeration value="ico"/>
|
||||
<enumeration value="op"/>
|
||||
<enumeration value="passport"/>
|
||||
<enumeration value="birthday"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ describe 'EPP Contact', epp: true do
|
|||
expect(response[:clTRID]).to eq('ABC-12345')
|
||||
|
||||
expect(Contact.first.name).to eq("John Doe")
|
||||
expect(Contact.first.ident_type).to eq("op")
|
||||
|
||||
expect(Contact.count).to eq(1)
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<contact:voice x="1234">+123.7035555555</contact:voice>
|
||||
<contact:fax>+1.7035555556</contact:fax>
|
||||
<contact:email>jdoe@example.com</contact:email>
|
||||
<contact:ident>37605030299</contact:ident>
|
||||
<contact:ident type="op">37605030299</contact:ident>
|
||||
<contact:authInfo>
|
||||
<contact:pw>2fooBAR</contact:pw>
|
||||
</contact:authInfo>
|
||||
|
|
|
@ -4,4 +4,5 @@ Fabricator(:contact) do
|
|||
email Faker::Internet.email
|
||||
ident '37605030299'
|
||||
code 'sh8913'
|
||||
ident_type 'op'
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue