mirror of
https://github.com/internetee/registry.git
synced 2025-07-26 04:28:27 +02:00
Contact creation improvements
This commit is contained in:
parent
acb65c47d6
commit
6a456240fa
7 changed files with 39 additions and 7 deletions
|
@ -1,5 +1,22 @@
|
||||||
module Epp::ContactsHelper
|
module Epp::ContactsHelper
|
||||||
def create_contact
|
def create_contact
|
||||||
cp = Hash.from_xml(parsed_frame.css("epp command create create").to_xml).with_indifferent_access
|
ph = get_params_hash('epp command create create')[:create]
|
||||||
|
|
||||||
|
@contact = Contact.new(
|
||||||
|
code: ph[:id],
|
||||||
|
name: ph[:postalInfo][:name],
|
||||||
|
phone: ph[:voice],
|
||||||
|
email: ph[:email],
|
||||||
|
reg_no: ph[:ident]
|
||||||
|
)
|
||||||
|
|
||||||
|
@contact.addresses << Address.new(
|
||||||
|
country_id: Country.find_by(iso: ph[:postalInfo][:cc]),
|
||||||
|
street: ph[:postalInfo][:street],
|
||||||
|
zip: ph[:postalInfo][:pc]
|
||||||
|
)
|
||||||
|
|
||||||
|
@contact.save
|
||||||
|
render '/epp/contacts/create'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@ xml.epp_head do
|
||||||
|
|
||||||
xml.resData do
|
xml.resData do
|
||||||
xml.tag!('contact:creData', 'xmlns:contact' => 'http://www.nic.cz/xml/epp/contact-1.6', 'xsi:schemaLocation' => 'http://www.nic.cz/xml/epp/contact-1.6 contact-1.6.xsd') do
|
xml.tag!('contact:creData', 'xmlns:contact' => 'http://www.nic.cz/xml/epp/contact-1.6', 'xsi:schemaLocation' => 'http://www.nic.cz/xml/epp/contact-1.6 contact-1.6.xsd') do
|
||||||
xml.tag!('contact:id', @id)
|
xml.tag!('contact:id', @contact.code)
|
||||||
xml.tag!('contact:crDate', @crDate)
|
xml.tag!('contact:crDate', @contact.created_at)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
5
db/migrate/20140702144833_countries_table_rename.rb
Normal file
5
db/migrate/20140702144833_countries_table_rename.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class CountriesTableRename < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_table :country_id, :countries
|
||||||
|
end
|
||||||
|
end
|
5
db/migrate/20140702145448_address_column_rename.rb
Normal file
5
db/migrate/20140702145448_address_column_rename.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddressColumnRename < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :addresses, :address, :street
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20140701130945) do
|
ActiveRecord::Schema.define(version: 20140702145448) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -20,7 +20,7 @@ ActiveRecord::Schema.define(version: 20140701130945) do
|
||||||
t.integer "contact_id"
|
t.integer "contact_id"
|
||||||
t.integer "country_id"
|
t.integer "country_id"
|
||||||
t.string "city"
|
t.string "city"
|
||||||
t.string "address"
|
t.string "street"
|
||||||
t.string "zip"
|
t.string "zip"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
@ -38,7 +38,7 @@ ActiveRecord::Schema.define(version: 20140701130945) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "country_id", force: true do |t|
|
create_table "countries", force: true do |t|
|
||||||
t.string "iso"
|
t.string "iso"
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
|
|
@ -5,3 +5,6 @@
|
||||||
#
|
#
|
||||||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
||||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
# Mayor.create(name: 'Emanuel', city: cities.first)
|
||||||
|
|
||||||
|
Country.where(name: 'Estonia', iso: 'EE').first_or_create
|
||||||
|
EppUser.where(username: 'gitlab', password: 'ghyt9e4fu', active: true).first_or_create
|
||||||
|
|
|
@ -11,7 +11,9 @@ describe 'EPP Contact', epp: true do
|
||||||
response = epp_request('contacts/create.xml')
|
response = epp_request('contacts/create.xml')
|
||||||
expect(response[:result_code]).to eq('1000')
|
expect(response[:result_code]).to eq('1000')
|
||||||
expect(response[:msg]).to eq('Command completed successfully')
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
expect(response[:clTRID]).to eq('ABC-12345')
|
expect(response[:clTRID]).to eq('neka005#10-02-08at13:51:37')
|
||||||
|
|
||||||
|
expect(Contact.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue