mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Refactor registrar address to smaller pieces
This commit is contained in:
parent
107767e241
commit
39ea06ab17
8 changed files with 57 additions and 22 deletions
|
@ -56,7 +56,7 @@ class Admin::RegistrarsController < AdminController
|
||||||
|
|
||||||
def registrar_params
|
def registrar_params
|
||||||
params.require(:registrar).permit(
|
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
|
:country_code, :email, :phone, :billing_email
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Registrar < ActiveRecord::Base
|
||||||
has_many :messages
|
has_many :messages
|
||||||
belongs_to :country_deprecated, foreign_key: :country_id
|
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
|
validates :name, :reg_no, uniqueness: true
|
||||||
after_save :touch_domains_version
|
after_save :touch_domains_version
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ class Registrar < ActiveRecord::Base
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def address
|
||||||
|
[street, city, state, city].reject(&:empty?).compact.join(', ')
|
||||||
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,22 +24,31 @@
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :phone
|
= f.label :phone
|
||||||
= f.text_field(:phone, class: 'form-control')
|
= 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
|
.form-group
|
||||||
= f.label :billing_email
|
= f.label :billing_email
|
||||||
= f.text_field(:billing_email, class: 'form-control')
|
= 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
|
%hr
|
||||||
.row
|
.row
|
||||||
.col-md-12.text-right
|
.col-md-12.text-right
|
||||||
|
|
|
@ -237,6 +237,7 @@ en:
|
||||||
billing_email: 'Billing e-mail'
|
billing_email: 'Billing e-mail'
|
||||||
phone: 'Contact phone'
|
phone: 'Contact phone'
|
||||||
email: 'Contact e-mail'
|
email: 'Contact e-mail'
|
||||||
|
state: 'State / Province'
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
messages:
|
messages:
|
||||||
|
|
|
@ -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
|
|
@ -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: 20150203074508) do
|
ActiveRecord::Schema.define(version: 20150203135303) 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"
|
||||||
|
@ -571,7 +571,6 @@ ActiveRecord::Schema.define(version: 20150203074508) do
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "reg_no"
|
t.string "reg_no"
|
||||||
t.string "vat_no"
|
t.string "vat_no"
|
||||||
t.string "address"
|
|
||||||
t.integer "country_id"
|
t.integer "country_id"
|
||||||
t.string "billing_address"
|
t.string "billing_address"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
|
@ -582,6 +581,10 @@ ActiveRecord::Schema.define(version: 20150203074508) do
|
||||||
t.string "email"
|
t.string "email"
|
||||||
t.string "billing_email"
|
t.string "billing_email"
|
||||||
t.string "country_code"
|
t.string "country_code"
|
||||||
|
t.string "state"
|
||||||
|
t.string "city"
|
||||||
|
t.string "street"
|
||||||
|
t.string "zip"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "reserved_domains", force: :cascade do |t|
|
create_table "reserved_domains", force: :cascade do |t|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
Fabricator(:registrar) do
|
Fabricator(:registrar) do
|
||||||
name { sequence(:name) { |i| "Registrar #{i}" } }
|
name { sequence(:name) { |i| "Registrar #{i}" } }
|
||||||
reg_no { sequence(:reg_no) { |i| "123#{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'
|
email 'info@registrar1.ee'
|
||||||
country_code 'EE'
|
country_code 'EE'
|
||||||
end
|
end
|
||||||
|
@ -9,13 +12,19 @@ end
|
||||||
Fabricator(:registrar1, from: :registrar) do
|
Fabricator(:registrar1, from: :registrar) do
|
||||||
name 'registrar1'
|
name 'registrar1'
|
||||||
reg_no '111'
|
reg_no '111'
|
||||||
address 'Street 111, Town, County, Postal'
|
street 'Street 111'
|
||||||
|
city 'Town'
|
||||||
|
state 'County'
|
||||||
|
zip 'Postal'
|
||||||
email 'info@registrar1.ee'
|
email 'info@registrar1.ee'
|
||||||
end
|
end
|
||||||
|
|
||||||
Fabricator(:registrar2, from: :registrar) do
|
Fabricator(:registrar2, from: :registrar) do
|
||||||
name 'registrar2'
|
name 'registrar2'
|
||||||
reg_no '222'
|
reg_no '222'
|
||||||
address 'Street 222, Town, County, Postal'
|
street 'Street 222'
|
||||||
|
city 'Town'
|
||||||
|
state 'County'
|
||||||
|
zip 'Postal'
|
||||||
email 'info@registrar2.ee'
|
email 'info@registrar2.ee'
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,9 +13,8 @@ describe Registrar do
|
||||||
it 'is not valid' do
|
it 'is not valid' do
|
||||||
@registrar.valid?
|
@registrar.valid?
|
||||||
@registrar.errors.full_messages.should match_array([
|
@registrar.errors.full_messages.should match_array([
|
||||||
'Address is missing',
|
|
||||||
'Contact e-mail is missing',
|
'Contact e-mail is missing',
|
||||||
'Country is missing',
|
'Country code is missing',
|
||||||
'Name is missing',
|
'Name is missing',
|
||||||
'Reg no is missing'
|
'Reg no is missing'
|
||||||
])
|
])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue