diff --git a/app/controllers/admin/registrars_controller.rb b/app/controllers/admin/registrars_controller.rb index aec7bebe4..ed9955518 100644 --- a/app/controllers/admin/registrars_controller.rb +++ b/app/controllers/admin/registrars_controller.rb @@ -56,7 +56,7 @@ class Admin::RegistrarsController < AdminController def registrar_params params.require(:registrar).permit( - :name, :reg_no, :vat_no, :address, :billing_address, + :name, :reg_no, :vat_no, :street, :city, :state, :zip, :billing_address, :country_code, :email, :phone, :billing_email ) end diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 3fd8521b5..f4a5e16ca 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -7,7 +7,7 @@ class Registrar < ActiveRecord::Base has_many :messages belongs_to :country_deprecated, foreign_key: :country_id - validates :name, :reg_no, :address, :country, :email, presence: true + validates :name, :reg_no, :country_code, :email, presence: true validates :name, :reg_no, uniqueness: true after_save :touch_domains_version @@ -22,6 +22,10 @@ class Registrar < ActiveRecord::Base ) end + def address + [street, city, state, city].reject(&:empty?).compact.join(', ') + end + def to_s name end diff --git a/app/views/admin/registrars/_form.haml b/app/views/admin/registrars/_form.haml index 1e145e403..40e4e8a37 100644 --- a/app/views/admin/registrars/_form.haml +++ b/app/views/admin/registrars/_form.haml @@ -24,22 +24,31 @@ .form-group = f.label :phone = f.text_field(:phone, class: 'form-control') - - .col-md-6.text-left - .form-group - = f.label :country_code - = f.text_field :country_code, class: 'form-control' - .form-group - = f.label :address - = f.text_field(:address, class: 'form-control') - %p.help-block= t('address_help') - .form-group - = f.label :billing_address - = f.text_field(:billing_address, class: 'form-control') - %p.help-block= t('address_help') .form-group = f.label :billing_email = f.text_field(:billing_email, class: 'form-control') + + .col-md-6.text-left + .form-group + = f.label :street + = f.text_field(:street, class: 'form-control') + .form-group + = f.label :city + = f.text_field(:city, class: 'form-control') + .form-group + = f.label :state + = f.text_field(:state, class: 'form-control') + .form-group + = f.label :zip + = f.text_field(:zip, class: 'form-control') + .form-group + = f.label :country_code + = f.text_field :country_code, class: 'form-control' + / EIS does not want Billing Address + / .form-group + / = f.label :billing_address + / = f.text_field(:billing_address, class: 'form-control') + / %p.help-block= t('address_help') %hr .row .col-md-12.text-right diff --git a/config/locales/en.yml b/config/locales/en.yml index 6ad2d4253..ff5cab3f6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -237,6 +237,7 @@ en: billing_email: 'Billing e-mail' phone: 'Contact phone' email: 'Contact e-mail' + state: 'State / Province' errors: messages: diff --git a/db/migrate/20150203135303_add_new_address_fields_to_registrar.rb b/db/migrate/20150203135303_add_new_address_fields_to_registrar.rb new file mode 100644 index 000000000..56126707a --- /dev/null +++ b/db/migrate/20150203135303_add_new_address_fields_to_registrar.rb @@ -0,0 +1,10 @@ +class AddNewAddressFieldsToRegistrar < ActiveRecord::Migration + def change + # get rid of old addresses, we will be migrating from the old db soon anyway + remove_column :registrars, :address, :string + add_column :registrars, :state, :string + add_column :registrars, :city, :string + add_column :registrars, :street, :string + add_column :registrars, :zip, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index c7ff5d055..26b58e3f9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150203074508) do +ActiveRecord::Schema.define(version: 20150203135303) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -571,7 +571,6 @@ ActiveRecord::Schema.define(version: 20150203074508) do t.string "name" t.string "reg_no" t.string "vat_no" - t.string "address" t.integer "country_id" t.string "billing_address" t.datetime "created_at" @@ -582,6 +581,10 @@ ActiveRecord::Schema.define(version: 20150203074508) do t.string "email" t.string "billing_email" t.string "country_code" + t.string "state" + t.string "city" + t.string "street" + t.string "zip" end create_table "reserved_domains", force: :cascade do |t| diff --git a/spec/fabricators/registrar_fabricator.rb b/spec/fabricators/registrar_fabricator.rb index 90dde766d..ae0bad96e 100644 --- a/spec/fabricators/registrar_fabricator.rb +++ b/spec/fabricators/registrar_fabricator.rb @@ -1,7 +1,10 @@ Fabricator(:registrar) do name { sequence(:name) { |i| "Registrar #{i}" } } reg_no { sequence(:reg_no) { |i| "123#{i}" } } - address 'Street 999, Town, County, Postal' + street 'Street 999' + city 'Town' + state 'County' + zip 'Postal' email 'info@registrar1.ee' country_code 'EE' end @@ -9,13 +12,19 @@ end Fabricator(:registrar1, from: :registrar) do name 'registrar1' reg_no '111' - address 'Street 111, Town, County, Postal' + street 'Street 111' + city 'Town' + state 'County' + zip 'Postal' email 'info@registrar1.ee' end Fabricator(:registrar2, from: :registrar) do name 'registrar2' reg_no '222' - address 'Street 222, Town, County, Postal' + street 'Street 222' + city 'Town' + state 'County' + zip 'Postal' email 'info@registrar2.ee' end diff --git a/spec/models/registrar_spec.rb b/spec/models/registrar_spec.rb index 195bce506..59418497c 100644 --- a/spec/models/registrar_spec.rb +++ b/spec/models/registrar_spec.rb @@ -13,9 +13,8 @@ describe Registrar do it 'is not valid' do @registrar.valid? @registrar.errors.full_messages.should match_array([ - 'Address is missing', 'Contact e-mail is missing', - 'Country is missing', + 'Country code is missing', 'Name is missing', 'Reg no is missing' ])