Merge pull request #932 from internetee/improve-registrant-area

Improve registrant area
This commit is contained in:
Timo Võhmar 2018-09-19 14:06:11 +03:00 committed by GitHub
commit 64d8be029c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 246 additions and 84 deletions

View file

@ -1,6 +1,7 @@
html html
position: relative position: relative
min-height: 100% min-height: 100%
overflow-y: scroll
body body
padding-bottom: 130px padding-bottom: 130px
@ -30,9 +31,6 @@ h1, h2, h3, h4
color: white !important color: white !important
background-size: 100% background-size: 100%
.semifooter
padding: 42px 0 80px 0
.confirmation .confirmation
padding: 40px 0 20px 0 padding: 40px 0 20px 0
.column-keys .column-keys

View file

@ -1,5 +1,6 @@
class Registrant::ContactsController < RegistrantController class Registrant::ContactsController < RegistrantController
helper_method :domain_ids helper_method :domain_ids
helper_method :domain
def show def show
@contact = Contact.where(id: contacts).find_by(id: params[:id]) @contact = Contact.where(id: contacts).find_by(id: params[:id])
@ -25,4 +26,19 @@ class Registrant::ContactsController < RegistrantController
BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_domain_ids BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_domain_ids
end end
end end
end
def domain
current_user_domains.find(params[:domain_id])
end
def current_user_domains
ident_cc, ident = current_registrant_user.registrant_ident.split '-'
begin
BusinessRegistryCache.fetch_associated_domains ident, ident_cc
rescue Soap::Arireg::NotAvailableError => error
flash[:notice] = I18n.t(error.json[:message])
Rails.logger.fatal("[EXCEPTION] #{error.to_s}")
current_registrant_user.domains
end
end
end

View file

@ -1,3 +1,9 @@
<ol class="breadcrumb">
<li><%= link_to t('registrant.domains.index.header'), registrant_domains_path %></li>
<li><%= link_to domain, registrant_domain_path(domain) %></li>
<li><%= t 'registrant.contacts.contact_index' %></li>
</ol>
<div class="page-header"> <div class="page-header">
<h1><%= @contact.name %></h1> <h1><%= @contact.name %></h1>
</div> </div>

View file

@ -1,6 +1,9 @@
<tr> <tr class="domain">
<td><%= link_to domain, registrant_domain_path(domain) %></td> <td><%= link_to domain, registrant_domain_path(domain) %></td>
<td><%= link_to domain.registrant.name, registrant_contact_path(domain.registrant) %></td> <td>
<%= link_to domain.registrant.name,
registrant_domain_contact_path(domain, domain.registrant) %>
</td>
<td><%= l domain.expire_time %></td> <td><%= l domain.expire_time %></td>
<td><%= link_to domain.registrar, registrant_registrar_path(domain.registrar) %></td> <td><%= link_to domain.registrar, registrant_registrar_path(domain.registrar) %></td>
</tr> </tr>

View file

@ -76,7 +76,7 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover table-bordered table-condensed"> <table class="table table-hover table-bordered table-condensed domains">
<thead> <thead>
<tr> <tr>
<th class="col-xs-2"> <th class="col-xs-2">

View file

@ -1,22 +0,0 @@
- panel_class = @domain.errors.messages[:admin_contacts] ? 'panel-danger' : 'panel-default'
.panel{class: panel_class}
.panel-heading.clearfix
= t('.title')
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-4'}= t(:name)
%th{class: 'col-xs-4'}= t(:id)
%th{class: 'col-xs-4'}= t(:email)
%tbody
- @domain.admin_contacts.each do |ac|
%tr
%td= link_to(ac, registrant_contact_path(ac))
%td= ac.code
%td= ac.email
- if @domain.errors.messages[:admin_contacts]
%tfoot
- @domain.errors.messages[:admin_contacts].each do |x|
%tr
%td{colspan: 4}= x

View file

@ -0,0 +1,7 @@
<% contact = domain_contact.contact %>
<tr class="<%= domain_contact.model_name.singular.dasherize %>">
<td><%= link_to contact, registrant_domain_contact_path(domain, contact) %></td>
<td><%= contact.code %></td>
<td><%= contact.email %></td>
</tr>

View file

@ -0,0 +1,24 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t ".header_#{domain_contacts.model_name.plural.underscore}" %>
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed
<%= domain_contacts.model_name.plural.dasherize %>">
<thead>
<tr>
<th class="col-xs-4"><%= Contact.human_attribute_name :name %></th>
<th class="col-xs-4"><%= Contact.human_attribute_name :code %></th>
<th class="col-xs-4"><%= Contact.human_attribute_name :email %></th>
</tr>
</thead>
<tbody>
<%= render partial: 'registrant/domains/partials/domain_contact',
collection: domain_contacts,
locals: { domain: domain } %>
</tbody>
</table>
</div>
</div>

View file

@ -13,7 +13,7 @@
<dt><%= t(:registered_at) %></dt> <dt><%= t(:registered_at) %></dt>
<dd><%= l(@domain.registered_at) %></dd> <dd><%= l(@domain.registered_at) %></dd>
<dt><%= t(:registrar_name) %></dt> <dt><%= Registrar.model_name.human %></dt>
<dd><%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %></dd> <dd><%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %></dd>
<dt><%= Domain.human_attribute_name :transfer_code %></dt> <dt><%= Domain.human_attribute_name :transfer_code %></dt>

View file

@ -1,19 +0,0 @@
.panel.panel-default
.panel-heading
%h3.panel-title= t('.title')
.panel-body
%dl.dl-horizontal
%dt= t(:name)
%dd= link_to(@domain.registrant.name, registrant_contact_path(@domain.registrant))
%dt= t(:id)
%dd= @domain.registrant_code
%dt= t(:identity_code)
%dd= @domain.registrant_ident
%dt= t(:email)
%dd= @domain.registrant_email
%dt= t(:phone)
%dd= @domain.registrant_phone

View file

@ -0,0 +1,26 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt><%= Registrant.human_attribute_name :name %></dt>
<dd>
<%= link_to registrant.name, registrant_domain_contact_path(domain, registrant) %>
</dd>
<dt><%= Registrant.human_attribute_name :code %></dt>
<dd><%= registrant.code %></dd>
<dt><%= Registrant.human_attribute_name :ident %></dt>
<dd><%= registrant.ident %></dd>
<dt><%= Registrant.human_attribute_name :email %></dt>
<dd><%= registrant.email %></dd>
<dt><%= Registrant.human_attribute_name :phone %></dt>
<dd><%= registrant.phone %></dd>
</dl>
</div>
</div>

View file

@ -1,22 +0,0 @@
- panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default'
#tech_contacts.panel{class: panel_class}
.panel-heading.clearfix
= t('.title')
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-4'}= t(:name)
%th{class: 'col-xs-4'}= t(:id)
%th{class: 'col-xs-4'}= t(:email)
%tbody
- @domain.tech_contacts.each do |tc|
%tr
%td= link_to(tc, registrant_contact_path(tc))
%td= tc.code
%td= tc.email
- if @domain.errors.messages[:tech_contacts]
%tfoot
- @domain.errors.messages[:tech_contacts].each do |x|
%tr
%td{colspan: 4}= x

View file

@ -1,23 +1,35 @@
<%= render 'shared/title', name: @domain.name %> <ol class="breadcrumb">
<li><%= link_to t('registrant.domains.index.header'), registrant_domains_path %></li>
</ol>
<div class="page-header">
<h1><%= @domain %></h1>
</div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<%= render 'registrant/domains/partials/general' %> <%= render 'registrant/domains/partials/general' %>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<%= render 'registrant/domains/partials/owner' %> <%= render partial: 'registrant/domains/partials/registrant',
locals: { registrant: @domain.registrant, domain: @domain } %>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<%= render 'registrant/domains/partials/tech_contacts' %> <%= render 'registrant/domains/partials/domain_contacts',
domain: @domain,
domain_contacts: @domain.tech_domain_contacts %>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<%= render 'registrant/domains/partials/admin_contacts' %> <%= render 'registrant/domains/partials/domain_contacts',
domain: @domain,
domain_contacts: @domain.admin_domain_contacts %>
</div> </div>
</div> </div>

View file

@ -1,6 +1,8 @@
en: en:
registrant: registrant:
contacts: contacts:
contact_index: Contacts
show: show:
general: general:
header: General header: General

View file

@ -8,12 +8,11 @@ en:
download_list: download_list:
registrant: Registrant registrant: Registrant
partials: partials:
owner: registrant:
title: Registrant header: Registrant
admin_contacts: domain_contacts:
title: Admin. contacts header_admin_domain_contacts: Administrative contacts
header_tech_domain_contacts: Technical contacts
tech_contacts:
title: Tech. contacts

View file

@ -136,8 +136,9 @@ Rails.application.routes.draw do
end end
resources :registrars, only: :show resources :registrars, only: :show
resources :contacts, only: :show
resources :domains, only: %i[index show] do resources :domains, only: %i[index show] do
resources :contacts, only: %i[show]
collection do collection do
get :download_list get :download_list
end end

View file

@ -9,6 +9,8 @@ john:
code: john-001 code: john-001
auth_info: cacb5b auth_info: cacb5b
uuid: eb2f2766-b44c-4e14-9f16-32ab1a7cb957 uuid: eb2f2766-b44c-4e14-9f16-32ab1a7cb957
created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
updated_at: <%= Time.zone.parse('2010-07-06').to_s(:db) %>
william: &william william: &william
name: William name: William

View file

@ -4,7 +4,11 @@ shop:
registrar: bestnames registrar: bestnames
registrant: john registrant: john
transfer_code: 65078d5 transfer_code: 65078d5
valid_to: 2010-07-05 registered_at: <%= Time.zone.parse('2010-07-04').to_s(:db) %>
valid_to: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
outzone_at: <%= Time.zone.parse('2010-07-06').to_s(:db) %>
delete_at: <%= Time.zone.parse('2010-07-07').to_s(:db) %>
force_delete_at: <%= Time.zone.parse('2010-07-08').to_s(:db) %>
period: 1 period: 1
period_unit: m period_unit: m
uuid: 1b3ee442-e8fe-4922-9492-8fcb9dccc69c uuid: 1b3ee442-e8fe-4922-9492-8fcb9dccc69c

View file

@ -0,0 +1,35 @@
require 'test_helper'
class RegistrantAreaContactDetailsTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)
@contact = contacts(:john)
Setting.days_to_keep_business_registry_cache = 1
travel_to Time.zone.parse('2010-07-05')
end
def test_general_data
visit registrant_domain_contact_url(domains(:shop), @contact)
assert_text 'Code john-001'
assert_text 'Name John'
assert_text 'Auth info'
assert_css('[value="cacb5b"]')
assert_text 'Ident 1234'
assert_text 'Email john@inbox.test'
assert_text 'Phone +555.555'
assert_text "Created at #{l Time.zone.parse('2010-07-05')}"
assert_text "Updated at #{l Time.zone.parse('2010-07-06')}"
end
def test_registrant_user_cannot_access_contact_when_given_domain_belongs_to_another_user
suppress(ActionView::Template::Error) do
visit registrant_domain_contact_url(domains(:metro), @contact)
assert_response :not_found
assert_no_text 'Name John'
end
end
end

View file

@ -0,0 +1,65 @@
require 'test_helper'
class RegistrantAreaDomainDetailsTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)
@domain = domains(:shop)
Setting.days_to_keep_business_registry_cache = 1
travel_to Time.zone.parse('2010-07-05')
end
def test_general_data
visit registrant_domain_url(@domain)
assert_text 'Name shop.test'
assert_text "Registered at #{l Time.zone.parse('2010-07-04')}"
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
assert_text 'Transfer code'
assert_css('[value="65078d5"]')
assert_text "Valid to #{l Time.zone.parse('2010-07-05')}"
assert_text "Outzone at #{l Time.zone.parse('2010-07-06')}"
assert_text "Delete at #{l Time.zone.parse('2010-07-07')}"
assert_text "Force delete at #{l Time.zone.parse('2010-07-08')}"
end
def test_registrant
visit registrant_domain_url(@domain)
assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
assert_text 'Code john-001'
assert_text 'Ident 1234'
assert_text 'Email john@inbox.test'
assert_text 'Phone +555.555'
end
def test_admin_contacts
visit registrant_domain_url(@domain)
within('.admin-domain-contacts') do
assert_link 'Jane', href: registrant_domain_contact_path(@domain, contacts(:jane))
assert_text 'jane-001'
assert_text 'jane@mail.test'
assert_css '.admin-domain-contact', count: 1
end
end
def test_tech_contacts
visit registrant_domain_url(@domain)
within('.tech-domain-contacts') do
assert_link 'William', href: registrant_domain_contact_path(@domain, contacts(:william))
assert_text 'william-001'
assert_text 'william@inbox.test'
assert_css '.tech-domain-contact', count: 2
end
end
def test_registrant_user_cannot_access_domains_of_other_users
suppress(ActiveRecord::RecordNotFound) do
visit registrant_domain_url(domains(:metro))
assert_response :not_found
assert_no_text 'metro.test'
end
end
end

View file

@ -0,0 +1,25 @@
require 'test_helper'
class RegistrantAreaDomainListTest < ApplicationSystemTestCase
setup do
sign_in users(:registrant)
@domain = domains(:shop)
Setting.days_to_keep_business_registry_cache = 1
travel_to Time.zone.parse('2010-07-05')
end
def test_show_domain_list
visit registrant_domains_url
assert_link 'shop.test', href: registrant_domain_path(@domain)
assert_link 'John', href: registrant_domain_contact_path(@domain, @domain.registrant)
assert_link 'Best Names', href: registrant_registrar_path(@domain.registrar)
assert_text l(Time.zone.parse('2010-07-05'))
assert_css '.domains .domain', count: 4
end
def test_do_not_show_domains_of_other_registrant_users
visit registrant_domains_url
assert_no_text 'metro.test'
end
end