Refactor registrars

#765
This commit is contained in:
Artur Beljajev 2017-11-20 08:10:59 +02:00
parent cee51e1ac5
commit 0f6a47d73d
47 changed files with 644 additions and 640 deletions

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,17 @@
<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 :vat_no %></dt>
<dd><%= registrar.vat_no %></dd>
<dt><%= Registrar.human_attribute_name :accounting_customer_code %></dt>
<dd><%= registrar.accounting_customer_code %></dd>
<dt><%= Registrar.human_attribute_name :billing_email %></dt>
<dd><%= registrar.billing_email %></dd>
</dl>
</div>
</div>

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

@ -1,5 +1,6 @@
<%= form_for([:admin, @registrar], html: { class: 'form-horizontal' }) do |f| %>
<%= render 'shared/full_errors', object: @registrar %>
<%= render 'form_errors', target: @registrar %>
<div class="row">
<div class="col-md-8">
<div class="panel panel-default">
@ -133,7 +134,9 @@
<%= 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? %>
<%= f.text_field :code, required: f.object.new_record?,
disabled: f.object.persisted?,
class: 'form-control' %>
</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

@ -1,5 +1,10 @@
<% 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}" %>
<ol class="breadcrumb">
<li><%= link_to t('admin.registrars.index.header'), admin_registrars_path %></li>
<li><%= link_to @registrar.name, admin_registrar_path(@registrar) %></li>
</ol>
<div class="page-header">
<h1><%= t '.header' %></h1>
</div>
<%= render 'form' %>

View file

@ -1,7 +1,15 @@
<% 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="page-header">
<div class="row">
<div class="col-sm-10">
<h1><%= t '.header' %></h1>
</div>
<div class="col-sm-2 text-right">
<%= link_to t('.new_btn'), new_admin_registrar_path, class: 'btn btn-primary' %>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
@ -12,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

@ -1,2 +1,9 @@
<%= render 'shared/title', name: t(:new_registrar) %>
<ol class="breadcrumb">
<li><%= link_to t('admin.registrars.index.header'), admin_registrars_path %></li>
</ol>
<div class="page-header">
<h1><%= t '.header' %></h1>
</div>
<%= render 'form' %>

View file

@ -1,218 +1,50 @@
<% 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 %>
<ol class="breadcrumb">
<li><%= link_to t('admin.registrars.index.header'), admin_registrars_path %></li>
</ol>
<div class="page-header">
<div class="row">
<div class="col-md-6">
<h1>
<%= @registrar.name %>
<% if @registrar.test_registrar? %>
<span class="text-danger"> (test)</span>
<% end %>
</h1>
</div>
<div class="col-md-6 text-right">
<%= link_to t('.edit_btn'), edit_admin_registrar_path(@registrar),
class: 'btn btn-primary' %>
<%= link_to t('.delete_btn'), admin_registrar_path(@registrar),
method: :delete,
data: { confirm: t('.delete_btn_confirm') },
class: 'btn btn-default' %>
</div>
</div>
</div>
<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>
<%= 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 'admin/registrars/show/preferences', registrar: registrar %>
<%= render 'contacts', registrar: @registrar %>
<%= render 'billing', registrar: @registrar %>
<%= render '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>
<%= render 'users', 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(: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,10 +16,10 @@
%dt= t(:name)
%dd= @registrar.name
%dt= t(:reg_no)
%dt= Registrar.human_attribute_name :reg_no
%dd= @registrar.reg_no
%dt= t(:vat_no)
%dt= Registrar.human_attribute_name :vat_no
%dd= @registrar.vat_no
%dt= t(:id)

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)
@ -16,7 +16,7 @@
%dt= t(:swift)
%dd= @invoice.seller_swift
%dt= t(:vat_no)
%dt= Registrar.human_attribute_name :vat_no
%dd= @invoice.seller_vat_no
%dt= t(:address)

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
@ -261,7 +261,7 @@
%br
= "#{t('reg_no')} #{@invoice.seller_reg_no}"
%br
= "#{t('vat_no')} #{@invoice.seller_vat_no}"
= "#{Registrar.human_attribute_name :vat_no} #{@invoice.seller_vat_no}"
.col-md-3.left
= @invoice.seller_phone