Revert "Registry 663"

This commit is contained in:
Timo Võhmar 2018-02-01 16:15:45 +02:00 committed by GitHub
parent 7ed42b6e82
commit 1690f49575
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 165 additions and 308 deletions

1
.reek
View file

@ -246,6 +246,7 @@ DuplicateMethodCall:
- Billing::Price#self.effective
- Billing::Price#self.valid
- BusinessRegistryCache#fetch_by_ident_and_cc
- BusinessRegistryCache#purge
- Certificate#parse_metadata
- Certificate#reload_apache
- Certificate#revoke!

View file

@ -1,7 +1,13 @@
#= require jquery
#= require jquery_ujs
#= require jquery.validate
#= require jquery.validate.additional-methods
#= require turbolinks
#= require bootstrap-sprockets
#= require jquery.nested_attributes
#= require shared/jquery.validate.bootstrap
#= require jquery-ui/datepicker
#= require select2
#= require datepicker
#= require shared/general
#= require registrar/application

View file

@ -5,7 +5,3 @@ input[type=number]::-webkit-inner-spin-button {
input[type=number] {
-moz-appearance: textfield;
}
.search-form .actions {
padding-top: 25px;
}

View file

@ -5,7 +5,6 @@
//= require 'select2-bootstrap'
@import shared/fonts
@import shared/general
@import forms
@import nprogress
@import nprogress-bootstrap
@import typeaheadjs

View file

@ -1,12 +1,13 @@
class Registrant::DomainsController < RegistrantController
def index
authorize! :view, :registrant_domains
params[:q] ||= {}
normalize_search_parameters do
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
end
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
authorize! :view, :registrant_domains
params[:q] ||= {}
normalize_search_parameters do
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
end
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
end
def show
@ -14,15 +15,19 @@ class Registrant::DomainsController < RegistrantController
authorize! :read, @domain
end
def set_domain
@domain = domains.find(params[:id])
end
def domain_verification_url
authorize! :view, :registrant_domains
dom = domains.find(params[:id])
if (dom.statuses.include?(DomainStatus::PENDING_UPDATE) || dom.statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)) &&
dom.pending_json.present?
dom.pending_json.present?
@domain = dom
confirm_path = get_confirm_path(dom.statuses)
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
@domain = dom
confirm_path = get_confirm_path(dom.statuses)
@verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}"
else
flash[:warning] = I18n.t('available_verification_url_not_found')
@ -47,12 +52,6 @@ class Registrant::DomainsController < RegistrantController
end
end
private
def set_domain
@domain = domains.find(params[:id])
end
def domains
ident_cc, ident = @current_user.registrant_ident.split '-'
begin
@ -83,4 +82,5 @@ class Registrant::DomainsController < RegistrantController
"#{ENV['registrant_url']}/registrant/domain_delete_confirms"
end
end
end
end

View file

@ -31,6 +31,12 @@ class Registrant::SessionsController < Devise::SessionsController
client = Digidoc::Client.new(endpoint)
client.logger = Rails.application.config.logger unless Rails.env.test?
if Rails.env.test? && phone == "123"
@user = ApiUser.find_by(identity_code: "14212128025")
sign_in(@user, event: :authentication)
return redirect_to registrant_root_url
end
# country_codes = {'+372' => 'EST'}
response = client.authenticate(
phone: "+372#{phone}",

View file

@ -19,17 +19,24 @@ authentication using electronic ID. Association through a business organisation
=end
class BusinessRegistryCache < ActiveRecord::Base
def associated_domain_ids
contact_ids = Contact.where(ident_type: 'org', ident: associated_businesses, ident_country_code: ident_country_code).pluck(:id)
# 1. load domains by business
# 2. load domains by person
def associated_contacts
contact_ids = Contact.where(ident_type: 'org', ident: associated_businesses, ident_country_code: 'EE').pluck(:id)
contact_ids += Contact.where(ident_type: 'priv', ident: ident, ident_country_code: ident_country_code).pluck(:id)
contact_ids
end
def associated_domain_ids
domain_ids = []
contact_ids = associated_contacts
unless contact_ids.blank?
domain_ids = DomainContact.distinct.where(contact_id: contact_ids).pluck(:domain_id)
end
domain_ids += Domain.where(registrant_id: contact_ids).pluck(:id)
domain_ids
end
@ -62,5 +69,15 @@ class BusinessRegistryCache < ActiveRecord::Base
def business_registry
Soap::Arireg.new
end
def purge
STDOUT << "#{Time.zone.now.utc} - Starting Purge of old BusinessRegistry data from cache\n" unless Rails.env.test?
purged = 0
BusinessRegistryCache.where('retrieved_on < ?',
Time.zone.now < Setting.days_to_keep_business_registry_cache.days).each do |br|
br.destroy and purged += 1
end
STDOUT << "#{Time.zone.now.utc} - Finished purging #{purged} old BusinessRegistry cache items\n" unless Rails.env.test?
end
end
end

View file

@ -2,14 +2,17 @@
%html{lang: I18n.locale.to_s}
%head
%meta{charset: "utf-8"}/
%meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}/
%meta{content: "width=device-width, initial-scale=1", name: "viewport"}/
%meta{content: "Full stack top-level domain (TLD) management.", name: "description"}/
%meta{content: "Gitlab LTD", name: "author"}/
- if content_for? :head_title
= yield :head_title
- else
%title= t(:registrant_head_title)
= csrf_meta_tags
= stylesheet_link_tag 'registrant-manifest', media: 'all'
= javascript_include_tag 'registrant-manifest'
= stylesheet_link_tag 'registrant-manifest', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'registrant-manifest', 'data-turbolinks-track' => true
= favicon_link_tag 'favicon.ico'
%body
/ Fixed navbar
@ -46,7 +49,7 @@
%footer.footer
.container
.row
%row
.col-md-6
= image_tag 'eis-logo-et.png'
.col-md-6.text-right

View file

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

View file

@ -0,0 +1,84 @@
= render 'shared/title', name: t(:domains)
.row
.col-md-12
= search_form_for [:registrant, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f|
.row
.col-md-3
.form-group
= f.label :name
= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name)
.col-md-3
.form-group
= f.label t(:registrant_ident)
= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident)
.row
.col-md-3
.form-group
= f.label t(:valid_to_from)
= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from)
.col-md-3
.form-group
= f.label t(:valid_to_until)
= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until)
.col-md-3
.form-group
= label_tag t(:results_per_page)
= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page)
.col-md-3{style: 'padding-top: 25px;'}
%button.btn.btn-primary
&nbsp;
%span.glyphicon.glyphicon-search
&nbsp;
%button.btn.btn-default.js-reset-form
= t(:clear_fields)
.row
.col-md-3
.btn-group{:role => "group"}
%button.btn.btn-default.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
Download
%span.caret
%ul.dropdown-menu
%li= link_to 'PDF', download_list_registrant_domains_path(q: params[:q], format: "pdf")
%li= link_to 'CSV', download_list_registrant_domains_path(q: params[:q], format: "csv")
.col-md-3
.col-md-3
.col-md-3
%hr
.row
.col-md-12
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-2'}
= sort_link(@q, 'name')
%th{class: 'col-xs-2'}
= sort_link(@q, 'registrant_name', t('.registrant'))
%th{class: 'col-xs-2'}
= sort_link(@q, 'valid_to', t(:valid_to))
%th{class: 'col-xs-2'}
= sort_link(@q, 'registrar_name', t(:registrar_name))
%tbody
- @domains.each do |x|
%tr
%td= link_to(x, registrant_domain_path(x))
%td= link_to(x.registrant.name, registrant_contact_path(x.registrant)) if x.registrant
%td= l(x.valid_to, format: :short)
%td= link_to(x.registrar, registrant_registrar_path(x.registrar)) if x.registrar
.row
.col-md-6
= paginate @domains
.col-md-6.text-right
.pagination
= t(:result_count, count: @domains.total_count)
:coffee
$(".js-reset-form").on "click", (e) ->
e.preventDefault();
window.location = "#{registrant_domains_path}"

View file

@ -1,111 +0,0 @@
<div class="page-header">
<h1><%= t '.header' %></h1>
</div>
<div class="row">
<div class="col-md-12">
<%= search_form_for [:registrant, @q], html: { class: 'search-form', autocomplete: 'off' } do |f| %>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<%= f.label :name, for: nil %>
<%= f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) %>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<%= f.label t(:registrant_ident), for: nil %>
<%= f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) %>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<%= f.label t(:valid_to_from), for: nil %>
<%= f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_from) %>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<%= f.label t(:valid_to_until), for: nil %>
<%= f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control js-datepicker', placeholder: t(:valid_to_until) %>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<%= label_tag t(:results_per_page) %>
<%= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) %>
</div>
</div>
<div class="col-md-3 actions">
<button class="btn btn-primary">
&nbsp;
<span class="glyphicon glyphicon-search"></span>
&nbsp;
</button>
<%= link_to(t('.reset_btn'), registrant_domains_path, class: 'btn btn-default') %>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="btn-group" role="group">
<button aria-expanded="false" aria-haspopup="true" class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button">
Download
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<%= link_to 'PDF', download_list_registrant_domains_path(q: params[:q], format: "pdf") %>
</li>
<li>
<%= link_to 'CSV', download_list_registrant_domains_path(q: params[:q], format: "csv") %>
</li>
</ul>
</div>
</div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
<div class="col-md-3"></div>
</div>
<% end %>
</div>
</div>
<hr/>
<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-2">
<%= sort_link(@q, 'name') %>
</th>
<th class="col-xs-2">
<%= sort_link(@q, 'registrant_name', t('.registrant')) %>
</th>
<th class="col-xs-2">
<%= sort_link(@q, 'valid_to', t(:valid_to)) %>
</th>
<th class="col-xs-2">
<%= sort_link(@q, 'registrar_name', t(:registrar_name)) %>
</th>
</tr>
</thead>
<tbody>
<%= render @domains %>
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<%= paginate @domains %>
</div>
<div class="col-md-6 text-right">
<div class="pagination">
<%= t(:result_count, count: @domains.total_count) %>
</div>
</div>
</div>

View file

@ -0,0 +1,17 @@
= render 'shared/title', name: @domain.name
.row
.col-md-6= render 'registrant/domains/partials/general'
.col-md-6= render 'registrant/domains/partials/owner'
.row
.col-md-12= render 'registrant/domains/partials/tech_contacts'
.row
.col-md-12= render 'registrant/domains/partials/admin_contacts'
.row
.col-md-12= render 'registrant/domains/partials/statuses'
.row
.col-md-12= render 'registrant/domains/partials/nameservers'
.row
.col-md-12= render 'registrant/domains/partials/dnskeys'
.row
.col-md-12= render 'registrant/domains/partials/keyrelays'

View file

@ -1,46 +0,0 @@
<%= render 'shared/title', name: @domain.name %>
<div class="row">
<div class="col-md-6">
<%= render 'registrant/domains/partials/general' %>
</div>
<div class="col-md-6">
<%= render 'registrant/domains/partials/owner' %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/tech_contacts' %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/admin_contacts' %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/statuses' %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/nameservers' %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/dnskeys' %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/keyrelays' %>
</div>
</div>

View file

@ -2,9 +2,7 @@ en:
registrant:
domains:
index:
header: Domains
registrant: Registrant
reset_btn: Reset
download_list:
registrant: Registrant

View file

@ -99,7 +99,7 @@ Rails.application.routes.draw do
namespace :registrant do
root 'domains#index'
resources :domains, only: %i[index show] do
resources :domains do
collection do
get :download_list
end
@ -107,6 +107,7 @@ Rails.application.routes.draw do
member do
get 'domain_verification_url'
end
end
# resources :invoices do

View file

@ -1,5 +0,0 @@
class RemoveDomainContactsContactType < ActiveRecord::Migration
def change
remove_column :domain_contacts, :contact_type, :string
end
end

View file

@ -1,5 +0,0 @@
class AddDomainContactsContactIdFk < ActiveRecord::Migration
def change
add_foreign_key :domain_contacts, :contacts, name: 'domain_contacts_contact_id_fk'
end
end

View file

@ -1,5 +0,0 @@
class AddDomainContactsDomainIdFk < ActiveRecord::Migration
def change
add_foreign_key :domain_contacts, :domains, name: 'domain_contacts_domain_id_fk'
end
end

View file

@ -884,6 +884,7 @@ CREATE TABLE domain_contacts (
id integer NOT NULL,
contact_id integer,
domain_id integer,
contact_type character varying,
created_at timestamp without time zone,
updated_at timestamp without time zone,
contact_code_cache character varying,
@ -4473,22 +4474,6 @@ ALTER TABLE ONLY contacts
ADD CONSTRAINT contacts_registrar_id_fk FOREIGN KEY (registrar_id) REFERENCES registrars(id);
--
-- Name: domain_contacts_contact_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY domain_contacts
ADD CONSTRAINT domain_contacts_contact_id_fk FOREIGN KEY (contact_id) REFERENCES contacts(id);
--
-- Name: domain_contacts_domain_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY domain_contacts
ADD CONSTRAINT domain_contacts_domain_id_fk FOREIGN KEY (domain_id) REFERENCES domains(id);
--
-- Name: domains_registrant_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@ -5075,9 +5060,3 @@ INSERT INTO schema_migrations (version) VALUES ('20171121233843');
INSERT INTO schema_migrations (version) VALUES ('20171123035941');
INSERT INTO schema_migrations (version) VALUES ('20180112080312');
INSERT INTO schema_migrations (version) VALUES ('20180112084221');
INSERT INTO schema_migrations (version) VALUES ('20180112084442');

View file

@ -812,6 +812,7 @@
<text text-anchor="start" x="1969" y="-1338.8" font-family="Times,serif" font-size="14.00">id :integer</text>
<text text-anchor="start" x="1969" y="-1323.8" font-family="Times,serif" font-size="14.00">contact_id :integer</text>
<text text-anchor="start" x="1969" y="-1308.8" font-family="Times,serif" font-size="14.00">domain_id :integer</text>
<text text-anchor="start" x="1969" y="-1293.8" font-family="Times,serif" font-size="14.00">contact_type :string</text>
<text text-anchor="start" x="1969" y="-1278.8" font-family="Times,serif" font-size="14.00">created_at :datetime</text>
<text text-anchor="start" x="1969" y="-1263.8" font-family="Times,serif" font-size="14.00">updated_at :datetime</text>
<text text-anchor="start" x="1969" y="-1248.8" font-family="Times,serif" font-size="14.00">contact_code_cache :string</text>
@ -1065,6 +1066,7 @@
<text text-anchor="start" x="1832" y="-661.3" font-family="Times,serif" font-size="14.00">id :integer</text>
<text text-anchor="start" x="1832" y="-646.3" font-family="Times,serif" font-size="14.00">contact_id :integer</text>
<text text-anchor="start" x="1832" y="-631.3" font-family="Times,serif" font-size="14.00">domain_id :integer</text>
<text text-anchor="start" x="1832" y="-616.3" font-family="Times,serif" font-size="14.00">contact_type :string</text>
<text text-anchor="start" x="1832" y="-601.3" font-family="Times,serif" font-size="14.00">created_at :datetime</text>
<text text-anchor="start" x="1832" y="-586.3" font-family="Times,serif" font-size="14.00">updated_at :datetime</text>
<text text-anchor="start" x="1832" y="-571.3" font-family="Times,serif" font-size="14.00">contact_code_cache :string</text>
@ -1343,6 +1345,7 @@
<text text-anchor="start" x="2151" y="-1338.8" font-family="Times,serif" font-size="14.00">id :integer</text>
<text text-anchor="start" x="2151" y="-1323.8" font-family="Times,serif" font-size="14.00">contact_id :integer</text>
<text text-anchor="start" x="2151" y="-1308.8" font-family="Times,serif" font-size="14.00">domain_id :integer</text>
<text text-anchor="start" x="2151" y="-1293.8" font-family="Times,serif" font-size="14.00">contact_type :string</text>
<text text-anchor="start" x="2151" y="-1278.8" font-family="Times,serif" font-size="14.00">created_at :datetime</text>
<text text-anchor="start" x="2151" y="-1263.8" font-family="Times,serif" font-size="14.00">updated_at :datetime</text>
<text text-anchor="start" x="2151" y="-1248.8" font-family="Times,serif" font-size="14.00">contact_code_cache :string</text>

Before

Width:  |  Height:  |  Size: 231 KiB

After

Width:  |  Height:  |  Size: 232 KiB

Before After
Before After

View file

@ -1,8 +0,0 @@
first:
ident: 1234
ident_country_code: US
associated_businesses:
- 1234
retrieved_on: 2010-07-05 10:30
created_at: 2010-07-05 10:30
updated_at: 2010-07-05 10:30

View file

@ -1,20 +0,0 @@
john:
name: John
ident: 1234
ident_type: priv
ident_country_code: US
registrar: acme
jane:
name: Jane
ident: 1234
ident_type: priv
ident_country_code: US
registrar: acme
acme_ltd:
name: Acme Ltd.
ident: 1234
ident_type: org
registrar: acme
ident_country_code: US

View file

@ -1,4 +0,0 @@
two_jane:
domain: two
contact: jane
type: AdminDomainContact

View file

@ -1,14 +0,0 @@
one:
name: one.test
registrar: valid
registrant: john
two:
name: two.test
registrar: valid
registrant: john
three:
name: three.test
registrar: valid
registrant: acme_ltd

View file

@ -14,7 +14,3 @@ admin:
country_code: US
roles:
- admin
registrant:
type: RegistrantUser
registrant_ident: US-1234

View file

@ -1,25 +0,0 @@
require 'test_helper'
class DomainsTest < ActionDispatch::IntegrationTest
def setup
login_as users(:registrant)
Setting.days_to_keep_business_registry_cache = 1
travel_to Time.zone.parse('2010-07-05')
end
def test_shows_domains_where_current_user_is_registrant
visit registrant_domains_url
assert_text 'one.test'
end
def test_shows_domains_where_current_user_is_contact_person
visit registrant_domains_url
assert_text 'two.test'
end
def test_shows_domains_where_current_user_has_associated_organizations
visit registrant_domains_url
assert_text 'three.test'
end
end