mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
commit
f330b3564d
36 changed files with 702 additions and 323 deletions
|
@ -78,7 +78,8 @@ module Admin
|
||||||
:billing_email,
|
:billing_email,
|
||||||
:code,
|
:code,
|
||||||
:test_registrar,
|
:test_registrar,
|
||||||
:accounting_customer_code)
|
:accounting_customer_code,
|
||||||
|
:language)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,6 +16,8 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
helper_method :registrant_request?, :registrar_request?, :admin_request?, :current_root_url
|
helper_method :registrant_request?, :registrar_request?, :admin_request?, :current_root_url
|
||||||
|
helper_method :available_languages
|
||||||
|
|
||||||
def registrant_request?
|
def registrant_request?
|
||||||
request.path.match(/^\/registrant/)
|
request.path.match(/^\/registrant/)
|
||||||
end
|
end
|
||||||
|
@ -79,4 +81,10 @@ class ApplicationController < ActionController::Base
|
||||||
return if params[parent_key][key].blank?
|
return if params[parent_key][key].blank?
|
||||||
params[parent_key][key].sub!(/,/, '.')
|
params[parent_key][key].sub!(/,/, '.')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def available_languages
|
||||||
|
{ en: 'English', et: 'Estonian' }.invert
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,4 +7,11 @@ class DefaultFormBuilder < ActionView::Helpers::FormBuilder
|
||||||
def money_field(method, options = {})
|
def money_field(method, options = {})
|
||||||
@template.money_field(@object_name, method, objectify_options(options))
|
@template.money_field(@object_name, method, objectify_options(options))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def language_select(method, choices = nil, options = {}, html_options = {}, &block)
|
||||||
|
options[:selected] = @object.send(method) unless options[:selected]
|
||||||
|
@template.language_select(@object_name, method, choices, objectify_options(options),
|
||||||
|
@default_options.merge(html_options),
|
||||||
|
&block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,4 +12,9 @@ module FormHelper
|
||||||
|
|
||||||
text_field(object_name, method, options)
|
text_field(object_name, method, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def language_select(object, method, choices = nil, options = {}, html_options = {}, &block)
|
||||||
|
choices = options_for_select(available_languages, options[:selected])
|
||||||
|
select(object, method, choices, options, html_options, &block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,8 +16,11 @@ class Registrar < ActiveRecord::Base
|
||||||
validates :name, :reg_no, :country_code, :email, :code, presence: true
|
validates :name, :reg_no, :country_code, :email, :code, presence: true
|
||||||
validates :name, :reg_no, :reference_no, :code, uniqueness: true
|
validates :name, :reg_no, :reference_no, :code, uniqueness: true
|
||||||
validates :accounting_customer_code, presence: true
|
validates :accounting_customer_code, presence: true
|
||||||
|
validates :language, presence: true
|
||||||
validate :forbidden_codes
|
validate :forbidden_codes
|
||||||
|
|
||||||
|
after_initialize :set_defaults
|
||||||
|
|
||||||
def forbidden_codes
|
def forbidden_codes
|
||||||
return true unless ['CID'].include? code
|
return true unless ['CID'].include? code
|
||||||
errors.add(:code, I18n.t(:forbidden_code))
|
errors.add(:code, I18n.t(:forbidden_code))
|
||||||
|
@ -163,4 +166,10 @@ class Registrar < ActiveRecord::Base
|
||||||
return true unless Setting.api_ip_whitelist_enabled
|
return true unless Setting.api_ip_whitelist_enabled
|
||||||
white_ips.api.pluck(:ipv4, :ipv6).flatten.include?(ip)
|
white_ips.api.pluck(:ipv4, :ipv6).flatten.include?(ip)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_defaults
|
||||||
|
self.language = Setting.default_language unless language
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,6 +20,10 @@ class RegistrarPresenter
|
||||||
registrar.website
|
registrar.website
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def language
|
||||||
|
view.available_languages.key(registrar.language.to_sym)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :registrar
|
attr_reader :registrar
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
= form_for([:admin, @registrar], html: {class: 'form-horizontal'}) do |f|
|
|
||||||
= render 'shared/full_errors', object: @registrar
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col-md-8
|
|
||||||
.panel.panel-default
|
|
||||||
.panel-heading.clearfix
|
|
||||||
.pull-left= t(:general)
|
|
||||||
.panel-body
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :name
|
|
||||||
.col-md-7
|
|
||||||
= f.text_field(:name, class: 'form-control')
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :reg_no
|
|
||||||
.col-md-7
|
|
||||||
= f.text_field(:reg_no, class: 'form-control')
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :vat_no
|
|
||||||
.col-md-7
|
|
||||||
= f.text_field(:vat_no, class: 'form-control')
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :phone
|
|
||||||
.col-md-7
|
|
||||||
= f.text_field(:phone, class: 'form-control')
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :website
|
|
||||||
.col-md-7
|
|
||||||
= f.url_field :website, class: 'form-control'
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :email
|
|
||||||
.col-md-7
|
|
||||||
= f.email_field :email, class: 'form-control'
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :billing_email
|
|
||||||
.col-md-7
|
|
||||||
= f.email_field :billing_email, class: 'form-control'
|
|
||||||
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :accounting_customer_code
|
|
||||||
.col-md-7
|
|
||||||
= f.text_field :accounting_customer_code, class: 'form-control', required: true
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col-md-8
|
|
||||||
.panel.panel-default
|
|
||||||
.panel-heading.clearfix
|
|
||||||
.pull-left= t(:address)
|
|
||||||
.panel-body
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :street
|
|
||||||
.col-md-7
|
|
||||||
= f.text_field(:street, class: 'form-control')
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :city
|
|
||||||
.col-md-7
|
|
||||||
= f.text_field(:city, class: 'form-control')
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :state
|
|
||||||
.col-md-7
|
|
||||||
= f.text_field(:state, class: 'form-control')
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :zip
|
|
||||||
.col-md-7
|
|
||||||
= f.text_field(:zip, class: 'form-control')
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :country_code, t(:country)
|
|
||||||
.col-md-7
|
|
||||||
= f.select(:country_code,
|
|
||||||
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', disabled: !f.object.new_record?)
|
|
||||||
.form-group
|
|
||||||
.col-md-4.control-label
|
|
||||||
= f.label :test_registrar
|
|
||||||
.col-md-7
|
|
||||||
= f.check_box :test_registrar, class: 'form-control'
|
|
||||||
|
|
||||||
%hr
|
|
||||||
.row
|
|
||||||
.col-md-8.text-right
|
|
||||||
= button_tag(t(".#{f.object.new_record? ? 'create' : 'update'}_btn"), class: 'btn btn-success')
|
|
165
app/views/admin/registrars/_form.html.erb
Normal file
165
app/views/admin/registrars/_form.html.erb
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
<%= form_for([:admin, @registrar], html: { class: 'form-horizontal' }) do |f| %>
|
||||||
|
<%= render 'shared/full_errors', object: @registrar %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading clearfix">
|
||||||
|
<div class="pull-left">
|
||||||
|
<%= t(:general) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :name %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field :name, required: true, autofocus: true, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :reg_no %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field :reg_no, required: true, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :phone %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field(:phone, class: 'form-control') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :website %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.url_field :website, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :email %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.email_field :email, required: true, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading clearfix">
|
||||||
|
<div class="pull-left">
|
||||||
|
<%= t(:address) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :street %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field(:street, class: 'form-control') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :city %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field(:city, class: 'form-control') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :state %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field(:state, class: 'form-control') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :zip %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field(:zip, class: 'form-control') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :country_code, t(:country) %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.select(:country_code, SortedCountry.all_options(f.object.country_code), {}, class: 'form-control') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render 'admin/registrars/form/billing', f: f %>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading clearfix">
|
||||||
|
<div class="pull-left">
|
||||||
|
<%= t('.misc') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :code %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field :code, required: f.object.new_record?, class: 'form-control', disabled: !f.object.new_record? %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :test_registrar %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.check_box :test_registrar, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<%= render 'admin/registrars/form/preferences', f: f %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8 text-right">
|
||||||
|
<%= button_tag(t(".#{f.object.new_record? ? 'create' : 'update'}_btn"), class: 'btn btn-success') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -1,5 +0,0 @@
|
||||||
- content_for :actions do
|
|
||||||
= link_to(t(:back_to_registrar), [:admin, @registrar], class: 'btn btn-default')
|
|
||||||
= render 'shared/title', name: "#{t(:edit)}: #{@registrar.name}"
|
|
||||||
|
|
||||||
= render 'form'
|
|
5
app/views/admin/registrars/edit.html.erb
Normal file
5
app/views/admin/registrars/edit.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<% content_for :actions do %>
|
||||||
|
<%= link_to(t(:back_to_registrar), [:admin, @registrar], class: 'btn btn-default') %>
|
||||||
|
<% end %>
|
||||||
|
<%= render 'shared/title', name: "#{t(:edit)}: #{@registrar.name}" %>
|
||||||
|
<%= render 'form' %>
|
40
app/views/admin/registrars/form/_billing.html.erb
Normal file
40
app/views/admin/registrars/form/_billing.html.erb
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading clearfix">
|
||||||
|
<div class="pull-left">
|
||||||
|
<%= t '.header' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :vat_no %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field :vat_no, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :accounting_customer_code %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.text_field :accounting_customer_code, class: 'form-control', required: true %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :billing_email %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.email_field :billing_email, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
16
app/views/admin/registrars/form/_preferences.html.erb
Normal file
16
app/views/admin/registrars/form/_preferences.html.erb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<%= t '.header' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-4 control-label">
|
||||||
|
<%= f.label :language %>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-7">
|
||||||
|
<%= f.language_select :language, nil, {}, required: true, class: 'form-control' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,28 +0,0 @@
|
||||||
- content_for :actions do
|
|
||||||
= link_to(t('.new_btn'), new_admin_registrar_path, class: 'btn btn-primary')
|
|
||||||
= render 'shared/title', name: t(:registrars)
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col-md-12
|
|
||||||
.table-responsive
|
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
|
||||||
%thead
|
|
||||||
%tr
|
|
||||||
%th{class: 'col-xs-4'}
|
|
||||||
= sort_link(@q, 'name')
|
|
||||||
%th{class: 'col-xs-4'}
|
|
||||||
= sort_link(@q, 'reg_no', t(:reg_no))
|
|
||||||
%th{class: 'col-xs-4'}
|
|
||||||
= t(:credit_balance)
|
|
||||||
%th{class: 'col-xs-4'}
|
|
||||||
= t(:test_registrar)
|
|
||||||
%tbody
|
|
||||||
- @registrars.each do |x|
|
|
||||||
%tr
|
|
||||||
%td= link_to(x, [:admin, x])
|
|
||||||
%td= x.reg_no
|
|
||||||
%td= "#{x.balance}"
|
|
||||||
%td= "#{x.test_registrar}"
|
|
||||||
.row
|
|
||||||
.col-md-12
|
|
||||||
= paginate @registrars
|
|
51
app/views/admin/registrars/index.html.erb
Normal file
51
app/views/admin/registrars/index.html.erb
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<% content_for :actions do %>
|
||||||
|
<%= link_to(t('.new_btn'), new_admin_registrar_path, class: 'btn btn-primary') %>
|
||||||
|
<% end %>
|
||||||
|
<%= render 'shared/title', name: t(:registrars) %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="col-xs-4">
|
||||||
|
<%= sort_link(@q, 'name') %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-4">
|
||||||
|
<%= sort_link(@q, 'reg_no', t(:reg_no)) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-4">
|
||||||
|
<%= t(:credit_balance) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-4">
|
||||||
|
<%= t(:test_registrar) %>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @registrars.each do |x| %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%= link_to(x, [:admin, x]) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= x.reg_no %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= "#{x.balance}" %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= "#{x.test_registrar}" %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<%= paginate @registrars %>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,3 +0,0 @@
|
||||||
= render 'shared/title', name: t(:new_registrar)
|
|
||||||
|
|
||||||
= render 'form'
|
|
2
app/views/admin/registrars/new.html.erb
Normal file
2
app/views/admin/registrars/new.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<%= render 'shared/title', name: t(:new_registrar) %>
|
||||||
|
<%= render 'form' %>
|
|
@ -1,118 +0,0 @@
|
||||||
- content_for :actions do
|
|
||||||
= link_to(t(:edit), edit_admin_registrar_path(@registrar), class: 'btn btn-primary')
|
|
||||||
= link_to(t(:delete), admin_registrar_path(@registrar),
|
|
||||||
method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger')
|
|
||||||
- content_for :page_name do
|
|
||||||
= @registrar.name
|
|
||||||
- if @registrar.test_registrar?
|
|
||||||
%span{style: "color: #c9302c;"} (test)
|
|
||||||
= render 'shared/title', name: @registrar.name
|
|
||||||
|
|
||||||
- if @registrar.errors.any?
|
|
||||||
- @registrar.errors.each do |attr, err|
|
|
||||||
= err
|
|
||||||
%br
|
|
||||||
- if @registrar.errors.any?
|
|
||||||
%hr
|
|
||||||
.row
|
|
||||||
.col-md-6
|
|
||||||
.panel.panel-default
|
|
||||||
.panel-heading
|
|
||||||
%h3.panel-title= t(:general)
|
|
||||||
.panel-body
|
|
||||||
%dl.dl-horizontal
|
|
||||||
%dt= t(:name)
|
|
||||||
%dd= @registrar.name
|
|
||||||
|
|
||||||
%dt= t(:reg_no)
|
|
||||||
%dd= @registrar.reg_no
|
|
||||||
|
|
||||||
%dt= t(:vat_no)
|
|
||||||
%dd= @registrar.vat_no
|
|
||||||
|
|
||||||
%dt= t(:reference_no)
|
|
||||||
%dd= @registrar.reference_no
|
|
||||||
|
|
||||||
%dt= t(:id)
|
|
||||||
%dd= @registrar.code
|
|
||||||
|
|
||||||
%dt= t(:credit_balance)
|
|
||||||
%dd= @registrar.balance
|
|
||||||
|
|
||||||
%dt= Registrar.human_attribute_name :website
|
|
||||||
%dd= @registrar.website
|
|
||||||
|
|
||||||
%dt= Registrar.human_attribute_name :accounting_customer_code
|
|
||||||
%dd= @registrar.accounting_customer_code
|
|
||||||
|
|
||||||
.col-md-6
|
|
||||||
.panel.panel-default
|
|
||||||
.panel-heading
|
|
||||||
%h3.panel-title= t(:contact)
|
|
||||||
.panel-body
|
|
||||||
%dl.dl-horizontal
|
|
||||||
%dt= t(:country)
|
|
||||||
%dd= @registrar.country
|
|
||||||
|
|
||||||
%dt= t(:address)
|
|
||||||
%dd= @registrar.address
|
|
||||||
|
|
||||||
%dt= t(:contact_phone)
|
|
||||||
%dd= @registrar.phone
|
|
||||||
|
|
||||||
%dt= t(:contact_email)
|
|
||||||
%dd= @registrar.email
|
|
||||||
|
|
||||||
%dt= t(:billing_address)
|
|
||||||
%dd= @registrar.billing_address
|
|
||||||
|
|
||||||
%dt= t(:billing_email)
|
|
||||||
%dd= @registrar.billing_email
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col-md-12
|
|
||||||
#epp-users.panel.panel-default
|
|
||||||
.panel-heading.clearfix
|
|
||||||
.pull-left
|
|
||||||
= t('.api_users')
|
|
||||||
.pull-right
|
|
||||||
= link_to(t('.new_api_use_btn'), new_admin_registrar_api_user_path(@registrar), class: 'btn btn-default btn-xs')
|
|
||||||
|
|
||||||
.table-responsive
|
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
|
||||||
%thead
|
|
||||||
%tr
|
|
||||||
%th{class: 'col-xs-6'}= t(:username)
|
|
||||||
%th{class: 'col-xs-6'}= t('.active')
|
|
||||||
%tbody
|
|
||||||
- @registrar.api_users.each do |x|
|
|
||||||
%tr
|
|
||||||
%td= link_to(x, [:admin, x])
|
|
||||||
%td= x.active
|
|
||||||
|
|
||||||
.row
|
|
||||||
.col-md-12
|
|
||||||
#epp-users.panel.panel-default
|
|
||||||
.panel-heading.clearfix
|
|
||||||
.pull-left
|
|
||||||
= t(:white_ips)
|
|
||||||
.pull-right
|
|
||||||
= link_to(t(:create_new_white_ip), new_admin_registrar_white_ip_path(@registrar), class: 'btn btn-default btn-xs')
|
|
||||||
|
|
||||||
.table-responsive
|
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
|
||||||
%thead
|
|
||||||
%tr
|
|
||||||
%th{class: 'col-xs-4'}= t(:ipv4)
|
|
||||||
%th{class: 'col-xs-6'}= t(:ipv6)
|
|
||||||
%th{class: 'col-xs-2'}= t(:interfaces)
|
|
||||||
%tbody
|
|
||||||
- @registrar.white_ips.each do |x|
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
- if x.ipv4.present?
|
|
||||||
= link_to(x.ipv4, [:admin, @registrar, x])
|
|
||||||
%td
|
|
||||||
- if x.ipv6.present?
|
|
||||||
= link_to(x.ipv6, [:admin, @registrar, x])
|
|
||||||
%td= x.interfaces.join(', ').upcase
|
|
224
app/views/admin/registrars/show.html.erb
Normal file
224
app/views/admin/registrars/show.html.erb
Normal file
|
@ -0,0 +1,224 @@
|
||||||
|
<% registrar = RegistrarPresenter.new(registrar: @registrar, view: self) %>
|
||||||
|
<% content_for :actions do %>
|
||||||
|
<%= link_to(t(:edit), edit_admin_registrar_path(@registrar), class: 'btn btn-primary') %>
|
||||||
|
<%= link_to(t(:delete), admin_registrar_path(@registrar), method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger') %>
|
||||||
|
<% end %>
|
||||||
|
<% content_for :page_name do %>
|
||||||
|
<%= @registrar.name %>
|
||||||
|
<% if @registrar.test_registrar? %>
|
||||||
|
<span style="color: #c9302c;">(test)</span>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<%= render 'shared/title', name: @registrar.name %>
|
||||||
|
<% if @registrar.errors.any? %>
|
||||||
|
<% @registrar.errors.each do |attr, err| %>
|
||||||
|
<%= err %>
|
||||||
|
<br/>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% if @registrar.errors.any? %>
|
||||||
|
<hr/>
|
||||||
|
<% end %>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">
|
||||||
|
<%= t(:general) %>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>
|
||||||
|
<%= t(:name) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.name %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:reg_no) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.reg_no %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:vat_no) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.vat_no %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:reference_no) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.reference_no %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:id) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.code %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:credit_balance) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.balance %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= Registrar.human_attribute_name :website %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.website %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= Registrar.human_attribute_name :accounting_customer_code %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.accounting_customer_code %>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">
|
||||||
|
<%= t(:contact) %>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>
|
||||||
|
<%= t(:country) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.country %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:address) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.address %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:contact_phone) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.phone %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:contact_email) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.email %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:billing_address) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.billing_address %>
|
||||||
|
</dd>
|
||||||
|
<dt>
|
||||||
|
<%= t(:billing_email) %>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<%= @registrar.billing_email %>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%= render 'admin/registrars/show/preferences', registrar: registrar %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="panel panel-default" id="epp-users">
|
||||||
|
<div class="panel-heading clearfix">
|
||||||
|
<div class="pull-left">
|
||||||
|
<%= t('.api_users') %>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
<%= link_to(t('.new_api_use_btn'), new_admin_registrar_api_user_path(@registrar), class: 'btn btn-default btn-xs') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="col-xs-6">
|
||||||
|
<%= t(:username) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-6">
|
||||||
|
<%= t('.active') %>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @registrar.api_users.each do |x| %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%= link_to(x, [:admin, x]) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= x.active %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="panel panel-default" id="epp-users">
|
||||||
|
<div class="panel-heading clearfix">
|
||||||
|
<div class="pull-left">
|
||||||
|
<%= t(:white_ips) %>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
<%= link_to(t(:create_new_white_ip), new_admin_registrar_white_ip_path(@registrar), class: 'btn btn-default btn-xs') %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover table-bordered table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="col-xs-4">
|
||||||
|
<%= t(:ipv4) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-6">
|
||||||
|
<%= t(:ipv6) %>
|
||||||
|
</th>
|
||||||
|
<th class="col-xs-2">
|
||||||
|
<%= t(:interfaces) %>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @registrar.white_ips.each do |x| %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<% if x.ipv4.present? %>
|
||||||
|
<%= link_to(x.ipv4, [:admin, @registrar, x]) %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if x.ipv6.present? %>
|
||||||
|
<%= link_to(x.ipv6, [:admin, @registrar, x]) %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= x.interfaces.join(', ').upcase %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
12
app/views/admin/registrars/show/_preferences.html.erb
Normal file
12
app/views/admin/registrars/show/_preferences.html.erb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<%= t '.header' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt><%= Registrar.human_attribute_name :language %></dt>
|
||||||
|
<dd><%= registrar.language %></dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -50,6 +50,13 @@
|
||||||
= render 'setting_row', var: :request_confirmation_on_domain_deletion_enabled
|
= render 'setting_row', var: :request_confirmation_on_domain_deletion_enabled
|
||||||
= render 'setting_row', var: :address_processing
|
= render 'setting_row', var: :address_processing
|
||||||
|
|
||||||
|
%tr
|
||||||
|
%td.col-md-6= label_tag :default_language
|
||||||
|
%td.col-md-6
|
||||||
|
= select_tag '[settings][default_language]',
|
||||||
|
options_for_select(available_languages, Setting.default_language),
|
||||||
|
class: 'form-control'
|
||||||
|
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-heading
|
.panel-heading
|
||||||
= t('.billing')
|
= t('.billing')
|
||||||
|
|
|
@ -27,6 +27,7 @@ if con.present? && con.table_exists?('settings')
|
||||||
Setting.save_default(:request_confrimation_on_registrant_change_enabled, true)
|
Setting.save_default(:request_confrimation_on_registrant_change_enabled, true)
|
||||||
Setting.save_default(:request_confirmation_on_domain_deletion_enabled, true)
|
Setting.save_default(:request_confirmation_on_domain_deletion_enabled, true)
|
||||||
Setting.save_default(:address_processing, true)
|
Setting.save_default(:address_processing, true)
|
||||||
|
Setting.save_default(:default_language, 'en')
|
||||||
Setting.save_default(:nameserver_required, false)
|
Setting.save_default(:nameserver_required, false)
|
||||||
|
|
||||||
Setting.save_default(:client_side_status_editing_enabled, false)
|
Setting.save_default(:client_side_status_editing_enabled, false)
|
||||||
|
|
|
@ -9,6 +9,9 @@ en:
|
||||||
active: Active
|
active: Active
|
||||||
api_users: API users
|
api_users: API users
|
||||||
|
|
||||||
|
preferences:
|
||||||
|
header: Preferences
|
||||||
|
|
||||||
create:
|
create:
|
||||||
created: Registrar has been successfully created
|
created: Registrar has been successfully created
|
||||||
not_created: Unable to create registrar
|
not_created: Unable to create registrar
|
||||||
|
@ -21,3 +24,9 @@ en:
|
||||||
misc: Miscellaneous
|
misc: Miscellaneous
|
||||||
create_btn: Create registrar
|
create_btn: Create registrar
|
||||||
update_btn: Update registrar
|
update_btn: Update registrar
|
||||||
|
|
||||||
|
billing:
|
||||||
|
header: Billing
|
||||||
|
|
||||||
|
preferences:
|
||||||
|
header: Preferences
|
||||||
|
|
5
db/migrate/20171121233843_add_registrar_language.rb
Normal file
5
db/migrate/20171121233843_add_registrar_language.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddRegistrarLanguage < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :registrars, :language, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeRegistrarLanguageToNotNull < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column_null :registrars, :language, false, 'et'
|
||||||
|
end
|
||||||
|
end
|
|
@ -2477,7 +2477,8 @@ CREATE TABLE registrars (
|
||||||
vat boolean,
|
vat boolean,
|
||||||
legacy_id integer,
|
legacy_id integer,
|
||||||
reference_no character varying,
|
reference_no character varying,
|
||||||
test_registrar boolean DEFAULT false
|
test_registrar boolean DEFAULT false,
|
||||||
|
language character varying NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -5057,3 +5058,7 @@ INSERT INTO schema_migrations (version) VALUES ('20171025113808');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20171025153841');
|
INSERT INTO schema_migrations (version) VALUES ('20171025153841');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20171121233843');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20171123035941');
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,10 @@ RSpec.describe 'admin/registrars/_form' do
|
||||||
before :example do
|
before :example do
|
||||||
assign(:registrar, registrar)
|
assign(:registrar, registrar)
|
||||||
stub_template 'shared/_full_errors' => ''
|
stub_template 'shared/_full_errors' => ''
|
||||||
|
|
||||||
|
without_partial_double_verification do
|
||||||
|
allow(view).to receive(:available_languages).and_return({})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has website' do
|
it 'has website' do
|
|
@ -6,6 +6,10 @@ RSpec.describe 'admin/registrars/show' do
|
||||||
before :example do
|
before :example do
|
||||||
assign(:registrar, registrar)
|
assign(:registrar, registrar)
|
||||||
stub_template 'shared/_title' => ''
|
stub_template 'shared/_title' => ''
|
||||||
|
|
||||||
|
without_partial_double_verification do
|
||||||
|
allow(view).to receive(:available_languages).and_return({})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has website' do
|
it 'has website' do
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class RegistrarsControllerTest < ActionDispatch::IntegrationTest
|
|
||||||
def setup
|
|
||||||
login_as create(:admin_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_creates_new_registrar
|
|
||||||
assert_difference -> { Registrar.count } do
|
|
||||||
post admin_registrars_path, registrar: attributes_for(:registrar)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_redirects_to_newly_created_registrar
|
|
||||||
post admin_registrars_path, registrar: attributes_for(:registrar)
|
|
||||||
assert_redirected_to admin_registrar_path(Registrar.first)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class RegistrarsControllerTest < ActionDispatch::IntegrationTest
|
|
||||||
def setup
|
|
||||||
login_as create(:admin_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_accounting_customer_code
|
|
||||||
registrar = create(:registrar, accounting_customer_code: 'test accounting customer code')
|
|
||||||
visit admin_registrar_path(registrar)
|
|
||||||
assert_text 'test accounting customer code'
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -2,39 +2,29 @@ require 'test_helper'
|
||||||
|
|
||||||
class RegistrarsControllerTest < ActionDispatch::IntegrationTest
|
class RegistrarsControllerTest < ActionDispatch::IntegrationTest
|
||||||
def setup
|
def setup
|
||||||
login_as create(:admin_user)
|
login_as users(:admin)
|
||||||
|
@registrar = registrars(:valid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_updates_website
|
def test_updates_website
|
||||||
registrar = create(:registrar, website: 'test')
|
patch admin_registrar_path(@registrar), registrar: @registrar.attributes.merge(website: 'new.example.com')
|
||||||
|
@registrar.reload
|
||||||
|
|
||||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, website: 'new-website')
|
assert_equal 'new.example.com', @registrar.website
|
||||||
registrar.reload
|
|
||||||
|
|
||||||
assert_equal 'new-website', registrar.website
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_updates_email
|
def test_updates_email
|
||||||
registrar = create(:registrar, email: 'test@test.com')
|
patch admin_registrar_path(@registrar), registrar: @registrar.attributes.merge(email: 'new@example.com')
|
||||||
|
@registrar.reload
|
||||||
|
|
||||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, email: 'new-test@test.com')
|
assert_equal 'new@example.com', @registrar.email
|
||||||
registrar.reload
|
|
||||||
|
|
||||||
assert_equal 'new-test@test.com', registrar.email
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_updates_billing_email
|
def test_updates_billing_email
|
||||||
registrar = create(:registrar, billing_email: 'test@test.com')
|
patch admin_registrar_path(@registrar),
|
||||||
|
registrar: @registrar.attributes.merge(billing_email: 'new-billing@example.com')
|
||||||
|
@registrar.reload
|
||||||
|
|
||||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar, billing_email: 'new-test@test.com')
|
assert_equal 'new-billing@example.com', @registrar.billing_email
|
||||||
registrar.reload
|
|
||||||
|
|
||||||
assert_equal 'new-test@test.com', registrar.billing_email
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_redirects_to_registrar
|
|
||||||
registrar = create(:registrar)
|
|
||||||
patch admin_registrar_path(registrar), registrar: attributes_for(:registrar)
|
|
||||||
assert_redirected_to admin_registrar_path(registrar)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
21
test/fixtures/registrars.yml
vendored
Normal file
21
test/fixtures/registrars.yml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
DEFAULTS: &DEFAULTS
|
||||||
|
name: Acme Ltd
|
||||||
|
reg_no: 1234
|
||||||
|
country_code: US
|
||||||
|
email: acme@example.com
|
||||||
|
code: 1234
|
||||||
|
accounting_customer_code: ACCOUNT001
|
||||||
|
language: en
|
||||||
|
|
||||||
|
valid:
|
||||||
|
<<: *DEFAULTS
|
||||||
|
|
||||||
|
complete:
|
||||||
|
<<: *DEFAULTS
|
||||||
|
name: 2
|
||||||
|
reg_no: 2
|
||||||
|
code: 2
|
||||||
|
website: example.com
|
||||||
|
email: info@example.com
|
||||||
|
billing_email: billing@example.com
|
||||||
|
vat_no: US12345
|
16
test/fixtures/users.yml
vendored
Normal file
16
test/fixtures/users.yml
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
DEFAULTS: &DEFAULTS
|
||||||
|
username: test
|
||||||
|
|
||||||
|
api:
|
||||||
|
<<: *DEFAULTS
|
||||||
|
type: ApiUser
|
||||||
|
registrar: valid
|
||||||
|
roles:
|
||||||
|
- super
|
||||||
|
|
||||||
|
admin:
|
||||||
|
<<: *DEFAULTS
|
||||||
|
type: AdminUser
|
||||||
|
country_code: US
|
||||||
|
roles:
|
||||||
|
- admin
|
|
@ -2,16 +2,16 @@ require 'test_helper'
|
||||||
|
|
||||||
class EditRegistrarTest < ActionDispatch::IntegrationTest
|
class EditRegistrarTest < ActionDispatch::IntegrationTest
|
||||||
def setup
|
def setup
|
||||||
login_as create(:admin_user)
|
login_as users(:admin)
|
||||||
|
@registrar = registrars(:valid)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_updates_registrar
|
def test_updates_registrar
|
||||||
registrar = create(:registrar)
|
visit admin_registrar_path(@registrar)
|
||||||
|
|
||||||
visit admin_registrar_path(registrar)
|
|
||||||
click_link_or_button 'Edit'
|
click_link_or_button 'Edit'
|
||||||
click_link_or_button 'Update registrar'
|
click_link_or_button 'Update registrar'
|
||||||
|
|
||||||
|
assert_current_path admin_registrar_path(@registrar)
|
||||||
assert_text 'Registrar has been successfully updated'
|
assert_text 'Registrar has been successfully updated'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,20 +2,22 @@ require 'test_helper'
|
||||||
|
|
||||||
class NewRegistrarTest < ActionDispatch::IntegrationTest
|
class NewRegistrarTest < ActionDispatch::IntegrationTest
|
||||||
def setup
|
def setup
|
||||||
login_as create(:admin_user)
|
login_as users(:admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_registrar
|
def test_creates_registrar
|
||||||
visit admin_registrars_path
|
visit admin_registrars_path
|
||||||
click_link_or_button 'New registrar'
|
click_link_or_button 'New registrar'
|
||||||
|
|
||||||
fill_in 'registrar[name]', with: 'test'
|
fill_in 'registrar[name]', with: 'John Doe'
|
||||||
fill_in 'registrar[reg_no]', with: '1234567'
|
fill_in 'registrar[reg_no]', with: '1234567'
|
||||||
fill_in 'registrar[email]', with: 'test@test.com'
|
fill_in 'registrar[email]', with: 'test@test.com'
|
||||||
fill_in 'registrar[code]', with: 'test'
|
fill_in 'registrar[code]', with: 'test'
|
||||||
fill_in 'registrar[accounting_customer_code]', with: 'test'
|
fill_in 'registrar[accounting_customer_code]', with: 'test'
|
||||||
click_link_or_button 'Create registrar'
|
click_link_or_button 'Create registrar'
|
||||||
|
|
||||||
|
assert_current_path admin_registrar_path(Registrar.last)
|
||||||
assert_text 'Registrar has been successfully created'
|
assert_text 'Registrar has been successfully created'
|
||||||
|
assert_text 'John Doe'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
19
test/integration/admin/registrars/show_registrar_test.rb
Normal file
19
test/integration/admin/registrars/show_registrar_test.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ShowRegistrarTest < ActionDispatch::IntegrationTest
|
||||||
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
|
def setup
|
||||||
|
login_as users(:admin)
|
||||||
|
@registrar = registrars(:complete)
|
||||||
|
visit admin_registrar_path(@registrar)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_accounting_customer_code
|
||||||
|
assert_text 'ACCOUNT001'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_language
|
||||||
|
assert_text 'Language English'
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,9 +1,41 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class RegistrarTest < ActiveSupport::TestCase
|
class RegistrarTest < ActiveSupport::TestCase
|
||||||
|
def setup
|
||||||
|
@registrar = registrars(:valid)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_valid
|
||||||
|
assert @registrar.valid?
|
||||||
|
end
|
||||||
|
|
||||||
def test_rejects_absent_accounting_customer_code
|
def test_rejects_absent_accounting_customer_code
|
||||||
registrar = Registrar.new(accounting_customer_code: nil)
|
@registrar.accounting_customer_code = nil
|
||||||
registrar.validate
|
@registrar.validate
|
||||||
assert registrar.errors.added?(:accounting_customer_code, :blank)
|
assert @registrar.invalid?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_requires_country_code
|
||||||
|
@registrar.country_code = nil
|
||||||
|
@registrar.validate
|
||||||
|
assert @registrar.invalid?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_requires_language
|
||||||
|
@registrar.language = nil
|
||||||
|
@registrar.validate
|
||||||
|
assert @registrar.invalid?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_has_default_language
|
||||||
|
Setting.default_language = 'en'
|
||||||
|
registrar = Registrar.new
|
||||||
|
assert_equal 'en', registrar.language
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_overrides_default_language
|
||||||
|
Setting.default_language = 'en'
|
||||||
|
registrar = Registrar.new(language: 'de')
|
||||||
|
assert_equal 'de', registrar.language
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue