Merge branch 'master' into registry-623

# Conflicts:
#	app/controllers/admin/registrars_controller.rb
#	app/models/registrar.rb
#	app/views/admin/registrars/_billing.html.erb
#	app/views/admin/registrars/show.html.erb
#	config/locales/admin/registrars.en.yml
#	config/locales/en.yml
#	db/migrate/20180309053424_add_registrars_unique_constraints.rb
#	db/structure.sql
#	test/fixtures/registrars.yml
#	test/integration/admin/registrars/delete_test.rb
#	test/integration/admin/registrars/new_test.rb
#	test/models/registrar_test.rb
This commit is contained in:
Artur Beljajev 2018-03-29 12:09:13 +03:00
commit 837f326ef6
37 changed files with 232 additions and 245 deletions

2
.reek
View file

@ -191,7 +191,6 @@ DuplicateMethodCall:
- Registrant::SessionsController#mid_status
- Registrant::WhoisController#index
- Registrar::AccountActivitiesController#index
- Registrar::BaseController#check_ip
- Registrar::ContactsController#download_list
- Registrar::ContactsController#index
- Registrar::ContactsController#normalize_search_parameters
@ -667,7 +666,6 @@ TooManyStatements:
- Registrant::SessionsController#mid
- Registrant::SessionsController#mid_status
- Registrar::AccountActivitiesController#index
- Registrar::BaseController#check_ip
- Registrar::ContactsController#download_list
- Registrar::ContactsController#index
- Registrar::ContactsController#normalize_search_parameters

View file

@ -1,3 +1,10 @@
19.03.2018
* EPP transfer and REPP bulk transfer reuses contact objects [#746](https://github.com/internetee/registry/issues/746)
* Gems: Rack (1.6.9) and Rack-protection (1.5.5) update [#768](https://github.com/internetee/registry/issues/768)
* Removal of unused database tables [#756](https://github.com/internetee/registry/issues/756)
* Removal of unused date format [#764](https://github.com/internetee/registry/pull/764)
* Removal of billing postal address [#747](https://github.com/internetee/registry/issues/747)
06.03.2018
* BUG: Transfer poll message now returns affected domain name [#694](https://github.com/internetee/registry/issues/694)
* BUG: Successful REPP bulk transfer returns info about transfered domains [#693](https://github.com/internetee/registry/issues/693)

View file

@ -160,6 +160,7 @@ GEM
unicode_utils (~> 1.4)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.3)
daemons (1.2.4)
daemons-rails (1.2.1)
daemons
@ -247,7 +248,8 @@ GEM
activesupport (>= 3.0.0)
libxml-ruby (3.0.0)
liquid (3.0.6)
loofah (2.0.3)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.6)
mime-types (>= 1.16, < 4)

View file

@ -9,6 +9,7 @@
#= require select2
#= require jquery.doubleScroll
#= require datepicker
#= require spell_check
#= require admin/application
#= require admin/app
#= require_tree ./admin

View file

@ -4,4 +4,5 @@
#= require jquery-ui/datepicker
#= require select2
#= require datepicker
#= require spell_check
#= require shared/general

View file

@ -6,6 +6,7 @@
#= require jquery-ui/datepicker
#= require select2
#= require datepicker
#= require spell_check
#= require shared/general
#= require registrar/autocomplete
#= require registrar/application

View file

@ -0,0 +1,12 @@
(function() {
function disableSpellCheck() {
let selector = 'input[type=text], textarea';
let textFields = document.querySelectorAll(selector);
for (let field of textFields) {
field.spellcheck = false;
}
}
disableSpellCheck();
})();

View file

@ -43,8 +43,13 @@ module Admin
end
def destroy
@registrar.destroy!
redirect_to admin_registrars_url, notice: t('.deleted')
if @registrar.destroy
flash[:notice] = t('.deleted')
redirect_to admin_registrars_url
else
flash[:alert] = @registrar.errors.full_messages.first
redirect_to admin_registrar_url(@registrar)
end
end
private
@ -64,7 +69,6 @@ module Admin
:email,
:phone,
:website,
:billing_email,
:code,
:test_registrar,
:vat_no,

View file

@ -3,7 +3,7 @@ class Registrar
protect_from_forgery except: :back
skip_authorization_check # actually anyone can pay, no problems at all
skip_before_action :authenticate_user!, :check_ip, only: [:back]
skip_before_action :authenticate_user!, :check_ip_restriction, only: [:back]
before_action :check_bank
# to handle existing model we should

View file

@ -14,9 +14,10 @@ class Registrar < ActiveRecord::Base
delegate :balance, to: :cash_account, allow_nil: true
validates :name, :reg_no, :country_code, :email, :code, presence: true
validates :name, :reg_no, :reference_no, :code, uniqueness: true
validates :name, :reference_no, :code, uniqueness: true
validates :accounting_customer_code, presence: true
validates :language, presence: true
validate :forbid_special_code
validates :vat_rate, presence: true, if: 'foreign_vat_payer? && vat_no.blank?'
validates :vat_rate, absence: true, if: :home_vat_payer?

View file

@ -41,7 +41,7 @@
%dt= t(:currency)
%dd= @bank_transaction.currency
%dt= t(:reference_no)
%dt= BankTransaction.human_attribute_name :reference_no
%dd= @bank_transaction.reference_no
%dt= t(:paid_at)

View file

@ -0,0 +1,24 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</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><%= Registrar.human_attribute_name :billing_email %></dt>
<dd><%= @registrar.billing_email %></dd>
</dl>
</div>
</div>

View file

@ -0,0 +1,27 @@
<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 :name %></dt>
<dd><%= registrar.name %></dd>
<dt><%= Registrar.human_attribute_name :reg_no %></dt>
<dd><%= registrar.reg_no %></dd>
<dt><%= Registrar.human_attribute_name :reference_no %></dt>
<dd><%= registrar.reference_no %></dd>
<dt><%= Registrar.human_attribute_name :code %></dt>
<dd><%= registrar.code %></dd>
<dt><%= Registrar.human_attribute_name :balance %></dt>
<dd><%= registrar.balance %></dd>
<dt><%= Registrar.human_attribute_name :website %></dt>
<dd><%= registrar.website %></dd>
</dl>
</div>
</div>

View file

@ -0,0 +1,28 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th class="col-xs-6"><%= ApiUser.human_attribute_name :username %></th>
<th class="col-xs-6"><%= ApiUser.human_attribute_name :active %></th>
</tr>
</thead>
<tbody>
<% registrar.api_users.each do |user| %>
<tr>
<td><%= link_to(user, [:admin, user]) %></td>
<td><%= user.active %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="panel-footer text-right">
<%= link_to t('.new_btn'), new_admin_registrar_api_user_path(registrar),
class: 'btn btn-default btn-xs' %>
</div>
</div>

View file

@ -0,0 +1,38 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th class="col-xs-4"><%= WhiteIp.human_attribute_name :ipv4 %></th>
<th class="col-xs-6"><%= WhiteIp.human_attribute_name :ipv6 %></th>
<th class="col-xs-2"><%= WhiteIp.human_attribute_name :interfaces %></th>
</tr>
</thead>
<tbody>
<% registrar.white_ips.each do |white_ip| %>
<tr>
<td>
<% if white_ip.ipv4.present? %>
<%= link_to(white_ip.ipv4, [:admin, registrar, white_ip]) %>
<% end %>
</td>
<td>
<% if white_ip.ipv6.present? %>
<%= link_to(white_ip.ipv6, [:admin, registrar, white_ip]) %>
<% end %>
</td>
<td><%= white_ip.interfaces.join(', ').upcase %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="panel-footer text-right">
<%= link_to t('.new_btn'), new_admin_registrar_white_ip_path(registrar),
class: 'btn btn-default btn-xs' %>
</div>
</div>

View file

@ -20,10 +20,10 @@
<%= sort_link(@q, 'name') %>
</th>
<th class="col-xs-4">
<%= sort_link(@q, 'reg_no', t(:reg_no)) %>
<%= sort_link(@q, 'reg_no', Registrar.human_attribute_name(:reg_no)) %>
</th>
<th class="col-xs-4">
<%= t(:credit_balance) %>
<%= Registrar.human_attribute_name :balance %>
</th>
<th class="col-xs-4">
<%= t(:test_registrar) %>

View file

@ -26,198 +26,25 @@
</div>
</div>
<% 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(: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>
</dl>
</div>
</div>
<%= render 'details', registrar: @registrar %>
</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_email) %>
</dt>
<dd>
<%= @registrar.billing_email %>
</dd>
</dl>
</div>
</div>
<%= render 'contacts', registrar: @registrar %>
<%= render 'billing', registrar: @registrar %>
<%= render 'admin/registrars/show/preferences', registrar: registrar %>
<%= render 'preferences', registrar: registrar %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<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>
<%= render 'users', registrar: @registrar %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<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>
<%= render 'white_ips', registrar: @registrar %>
</div>
</div>

View file

@ -1,5 +1,5 @@
- content_for :actions do
= link_to(t(:back_to_registrar), admin_registrar_path(@registrar), class: 'btn btn-default')
= render 'shared/title', name: t(:create_new_white_ip)
= render 'shared/title', name: t('.header')
= render 'form'

View file

@ -14,11 +14,11 @@
%dt= t(:registrar_name)
%dd= link_to(@registrar, [:admin, @registrar])
%dt= t(:ipv4)
%dt= WhiteIp.human_attribute_name :ipv4
%dd= @white_ip.ipv4
%dt= t(:ipv6)
%dt= WhiteIp.human_attribute_name :ipv6
%dd= @white_ip.ipv6
%dt= t(:interfaces)
%dt= WhiteIp.human_attribute_name :interfaces
%dd= @white_ip.interfaces.join(', ').upcase

View file

@ -10,7 +10,7 @@
%th{class: 'col-xs-6'}
= sort_link(@q, 'name')
%th{class: 'col-xs-6'}
= sort_link(@q, 'reg_no', t(:reg_no))
= sort_link(@q, 'reg_no', Registrar.human_attribute_name(:reg_no))
%tbody
- @registrars.each do |x|
%tr

View file

@ -16,7 +16,7 @@
%dt= t(:name)
%dd= @registrar.name
%dt= t(:reg_no)
%dt= Registrar.human_attribute_name :reg_no
%dd= @registrar.reg_no
%dt= Registrar.human_attribute_name :vat_no

View file

@ -32,5 +32,5 @@
%dt= t(:description)
%dd=@invoice.description
%dt= t(:reference_no)
%dt= Invoice.human_attribute_name :reference_no
%dd= @invoice.reference_no

View file

@ -4,7 +4,7 @@
%dt= t(:name)
%dd= @invoice.seller_name
%dt= t(:reg_no)
%dt= Registrar.human_attribute_name :reg_no
%dd= @invoice.seller_reg_no
%dt= t(:iban)

View file

@ -182,7 +182,7 @@
%dt= t(:description)
%dd=@invoice.description
%dt= t(:reference_no)
%dt= Invoice.human_attribute_name :reference_no
%dd= @invoice.reference_no
.col-md-6.right

View file

@ -7,7 +7,6 @@
<div class="col-md-5">
<%= text_field_tag :old_hostname, params[:old_hostname], autofocus: true,
required: true,
spellcheck: false,
class: 'form-control' %>
</div>
</div>
@ -19,7 +18,6 @@
<div class="col-md-5">
<%= text_field_tag :new_hostname, params[:new_hostname], required: true,
spellcheck: false,
class: 'form-control' %>
</div>
</div>
@ -30,7 +28,7 @@
</div>
<div class="col-md-3">
<%= text_area_tag :ipv4, params[:ipv4], spellcheck: false, class: 'form-control' %>
<%= text_area_tag :ipv4, params[:ipv4], class: 'form-control' %>
</div>
</div>
@ -40,7 +38,7 @@
</div>
<div class="col-md-3">
<%= text_area_tag :ipv6, params[:ipv6], spellcheck: false, class: 'form-control' %>
<%= text_area_tag :ipv6, params[:ipv6], class: 'form-control' %>
<span class="help-block"><%= t '.ip_hint' %></span>
</div>
</div>

View file

@ -12,12 +12,12 @@ en:
edit_btn: Edit
delete_btn: Delete
delete_btn_confirm: Are you sure you want delete registrar?
new_api_use_btn: New API user
active: Active
api_users: API users
preferences:
header: Preferences
edit:
header: Edit registrar
billing:
header: Billing
edit:
header: Edit registrar
@ -44,3 +44,20 @@ en:
preferences:
header: Preferences
details:
header: Details
contacts:
header: Contacts
preferences:
header: Preferences
users:
header: API Users
new_btn: New API user
white_ips:
header: Whitelisted IPs
new_btn: New whitelisted IP

View file

@ -0,0 +1,5 @@
en:
admin:
white_ips:
new:
header: New whitelisted IP

View file

@ -202,9 +202,6 @@ en:
state: 'State / Province'
deposit:
amount: 'Amount'
white_ip:
ipv4: 'IPv4'
ipv6: 'IPv6'
errors:
messages:
@ -301,7 +298,6 @@ en:
reg_no: 'Reg. no'
status: 'Status'
contact: 'Contact'
credit_balance: 'Credit balance'
starting_balance: 'Starting balance'
destroyed: 'Destroyed'
@ -386,7 +382,6 @@ en:
choose: 'Choose...'
created_before: 'Created before'
created_after: 'Created after'
billing_email: 'Billing e-mail'
contact_phone: 'Contact phone'
contact_email: 'Contact e-mail'
address_help: 'Street name, house no - apartment no, city, county, country, zip'
@ -575,7 +570,6 @@ en:
queried_at: 'Queried at'
import_file_path: 'Import file path'
bank_code: 'Bank code'
reference_no: 'Reference no'
currency: 'Currency'
buyer_name: 'Buyer name'
buyer_iban: 'Buyer IBAN'
@ -652,8 +646,6 @@ en:
not_valid_domain_verification_body: This could mean your verification has been expired or done already.<br><br>Please contact us if you think something is wrong.
upload_crt: 'Upload CRT'
crt_or_csr_must_be_present: 'CRT or CSR must be present'
white_ips: 'White IP-s'
create_new_white_ip: 'Create new white IP'
ipv4_or_ipv6_must_be_present: 'IPv4 or IPv6 must be present'
white_ip: 'White IP'
edit_white_ip: 'Edit white IP'
@ -741,7 +733,6 @@ en:
failure: "It was not saved"
contact_is_not_valid: 'Contact %{value} is not valid, please fix the invalid contact'
welcome_to_eis_registrar_portal: 'Welcome to EIS Registrar portal'
interfaces: 'Interfaces'
next: 'Next'
previous: 'Previous'
personal_domain_verification_url: 'Personal domain verification url'
@ -771,3 +762,5 @@ en:
attributes:
vat_no: VAT number
vat_rate: VAT rate
ipv4: IPv4
ipv6: IPv6

View file

@ -97,7 +97,6 @@ Rails.application.routes.draw do
get 'pay/go/:bank' => 'payments#pay', as: 'payment_with'
end
# REGISTRANT ROUTES
namespace :registrant do
root 'domains#index'
@ -111,17 +110,6 @@ Rails.application.routes.draw do
end
end
# resources :invoices do
# member do
# get 'download_pdf'
# match 'forward', via: [:post, :get]
# patch 'cancel'
# end
# end
# resources :deposits
# resources :account_activities
resources :domain_update_confirms
resources :domain_delete_confirms
@ -150,8 +138,6 @@ Rails.application.routes.draw do
end
resources :registrars do
resources :api_users
resources :white_ips
collection do
get :search
end

View file

@ -2,7 +2,6 @@ class AddRegistrarsUniqueConstraints < ActiveRecord::Migration
def up
execute <<-SQL
ALTER TABLE registrars ADD CONSTRAINT unique_name UNIQUE (name);
ALTER TABLE registrars ADD CONSTRAINT unique_reg_no UNIQUE (reg_no);
ALTER TABLE registrars ADD CONSTRAINT unique_reference_no UNIQUE (reference_no);
ALTER TABLE registrars ADD CONSTRAINT unique_code UNIQUE (code);
SQL
@ -11,7 +10,6 @@ class AddRegistrarsUniqueConstraints < ActiveRecord::Migration
def down
execute <<-SQL
ALTER TABLE registrars DROP CONSTRAINT unique_name;
ALTER TABLE registrars DROP CONSTRAINT unique_reg_no;
ALTER TABLE registrars DROP CONSTRAINT unique_reference_no;
ALTER TABLE registrars DROP CONSTRAINT unique_code;
SQL

View file

@ -492,7 +492,6 @@
<polyline fill="none" stroke="black" points="-300,-378 -124,-378 "/>
<polyline fill="none" stroke="black" points="-300,-354 -124,-354 "/>
<text text-anchor="start" x="-292" y="-338.8" font-family="Times,serif" font-size="14.00">_layout</text>
<text text-anchor="start" x="-292" y="-323.8" font-family="Times,serif" font-size="14.00">check_ip</text>
<text text-anchor="start" x="-292" y="-308.8" font-family="Times,serif" font-size="14.00">role_base_root_url</text>
</g>
<!-- Registrar::PollsController -->

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Before After
Before After

View file

@ -41,3 +41,12 @@ complete:
language: en
vat_no: US12345
vat_rate: 0.05
not_in_use:
name: any
reg_no: any
code: any
email: any@example.com
country_code: US
accounting_customer_code: any
language: en

View file

@ -5,7 +5,7 @@ class AdminAreaDeleteRegistrarTest < ActionDispatch::IntegrationTest
login_as users(:admin)
end
def test_can_be_deleted_if_not_in_use
def test_can_be_deleted_when_not_in_use
visit admin_registrar_url(registrars(:not_in_use))
assert_difference 'Registrar.count', -1 do
@ -15,4 +15,16 @@ class AdminAreaDeleteRegistrarTest < ActionDispatch::IntegrationTest
assert_current_path admin_registrars_path
assert_text 'Registrar has been successfully deleted'
end
def test_cannot_be_deleted_when_in_use
registrar = registrars(:bestnames)
visit admin_registrar_url(registrar)
assert_no_difference 'Registrar.count' do
click_link_or_button 'Delete'
end
assert_current_path admin_registrar_path(registrar)
assert_text 'Cannot delete record because dependent domains exist'
end
end

View file

@ -9,10 +9,9 @@ class AdminAreaNewRegistrarTest < ActionDispatch::IntegrationTest
visit admin_registrars_url
click_link_or_button 'New registrar'
fill_in 'Name', with: 'Brand new name'
fill_in 'Name', with: 'Brand new names'
fill_in 'Reg no', with: '55555555'
fill_in 'Contact e-mail', with: 'test@example.com'
select 'United States', from: 'Country'
fill_in 'Accounting customer code', with: 'test'
fill_in 'Code', with: 'test'

View file

@ -24,13 +24,13 @@ class RegistrarTest < ActiveSupport::TestCase
assert @registrar.invalid?
end
def test_rejects_absent_accounting_customer_code
@registrar.accounting_customer_code = nil
def test_invalid_without_accounting_customer_code
@registrar.accounting_customer_code = ''
assert @registrar.invalid?
end
def test_invalid_without_country_code
@registrar.country_code = nil
@registrar.country_code = ''
assert @registrar.invalid?
end