mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 01:33:36 +02:00
Added registrar code
This commit is contained in:
parent
85efa5eb28
commit
8b22c58eec
7 changed files with 28 additions and 5 deletions
|
@ -57,7 +57,7 @@ class Admin::RegistrarsController < AdminController
|
||||||
def registrar_params
|
def registrar_params
|
||||||
params.require(:registrar).permit(
|
params.require(:registrar).permit(
|
||||||
:name, :reg_no, :vat_no, :street, :city, :state, :zip, :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, :code
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Registrar < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :country_deprecated, foreign_key: :country_id
|
belongs_to :country_deprecated, foreign_key: :country_id
|
||||||
|
|
||||||
validates :name, :reg_no, :country_code, :email, presence: true
|
validates :name, :reg_no, :country_code, :email, :code, presence: true
|
||||||
validates :name, :reg_no, :reference_no, uniqueness: true
|
validates :name, :reg_no, :reference_no, uniqueness: true
|
||||||
validate :set_code, if: :new_record?
|
validate :set_code, if: :new_record?
|
||||||
|
|
||||||
|
@ -139,7 +139,11 @@ class Registrar < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def code=(code)
|
def code=(code)
|
||||||
self[:code] = code if new_record?
|
self[:code] = code.upcase if new_record? && code.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def contact_prefix
|
||||||
|
"CID:#{code}:"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -70,6 +70,19 @@
|
||||||
.col-md-7
|
.col-md-7
|
||||||
= f.select(:country_code,
|
= f.select(:country_code,
|
||||||
SortedCountry.all_options(f.object.country_code), {}, class: 'form-control')
|
SortedCountry.all_options(f.object.country_code), {}, class: 'form-control')
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-8
|
||||||
|
.panel.panel-default
|
||||||
|
.panel-heading.clearfix
|
||||||
|
.pull-left= t(:misc)
|
||||||
|
.panel-body
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :code
|
||||||
|
.col-md-7
|
||||||
|
= f.text_field(:code, class: 'form-control')
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
.row
|
.row
|
||||||
.col-md-8.text-right
|
.col-md-8.text-right
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
%dt= t(:reference_no)
|
%dt= t(:reference_no)
|
||||||
%dd= @registrar.reference_no
|
%dd= @registrar.reference_no
|
||||||
|
|
||||||
|
%dt= t(:code)
|
||||||
|
%dd= @registrar.code
|
||||||
|
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-heading
|
.panel-heading
|
||||||
|
|
|
@ -86,7 +86,8 @@ namespace :import do
|
||||||
vat: x.vat,
|
vat: x.vat,
|
||||||
legacy_id: x.id,
|
legacy_id: x.id,
|
||||||
creator_str: user,
|
creator_str: user,
|
||||||
updator_str: user
|
updator_str: user,
|
||||||
|
code: x.handle.upcase
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ Fabricator(:registrar) do
|
||||||
zip 'Postal'
|
zip 'Postal'
|
||||||
email 'info@registrar1.ee'
|
email 'info@registrar1.ee'
|
||||||
country_code 'EE'
|
country_code 'EE'
|
||||||
|
code 'REG'
|
||||||
reference_no { sequence(:reference_no) { |i| "RF#{i}" } }
|
reference_no { sequence(:reference_no) { |i| "RF#{i}" } }
|
||||||
accounts(count: 1)
|
accounts(count: 1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,8 @@ describe Registrar do
|
||||||
'Contact e-mail is missing',
|
'Contact e-mail is missing',
|
||||||
'Country code is missing',
|
'Country code is missing',
|
||||||
'Name is missing',
|
'Name is missing',
|
||||||
'Reg no is missing'
|
'Reg no is missing',
|
||||||
|
'Code is missing',
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue