mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 18:29:40 +02:00
Merge branch '105846070-merge-with-105842700-arireg-for-registrant-port' into staging
This commit is contained in:
commit
a31801514b
19 changed files with 194 additions and 65 deletions
8
app/controllers/registrant/contacts_controller.rb
Normal file
8
app/controllers/registrant/contacts_controller.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class Registrant::ContactsController < RegistrantController
|
||||
|
||||
def show
|
||||
@contact = Contact.find(params[:id])
|
||||
authorize! :read, @contact
|
||||
@contact.valid?
|
||||
end
|
||||
end
|
|
@ -20,55 +20,44 @@ authentication using electronic ID. Association through a business organisation
|
|||
|
||||
class BusinessRegistryCache < ActiveRecord::Base
|
||||
|
||||
# 1. load domains by business
|
||||
# 2. load domains by person
|
||||
def associated_domains
|
||||
domains = []
|
||||
contact_ids = associated_businesses.map do |bic|
|
||||
Contact.select(:id).where("ident = ? AND ident_type = 'org' AND ident_country_code = 'EE'", bic).pluck(:id)
|
||||
end
|
||||
contact_ids = Contact.select(:id).where("ident = ? AND ident_type = 'priv' AND ident_country_code = ?",
|
||||
ident, ident_country_code).pluck(:id) + contact_ids
|
||||
contact_ids.flatten!.compact! unless contact_ids.blank?
|
||||
|
||||
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)
|
||||
|
||||
unless contact_ids.blank?
|
||||
contact_ids.uniq!
|
||||
domains = DomainContact.select(:domain_id).distinct.where("contact_id in (?)", contact_ids).pluck(:domain_id)
|
||||
domains = DomainContact.distinct.where(contact_id: contact_ids).pluck(:domain_id)
|
||||
end
|
||||
Domain.includes(:registrar, :registrant).where('id in (?)', domains)
|
||||
|
||||
Domain.includes(:registrar, :registrant).where(id: domains)
|
||||
end
|
||||
|
||||
class << self
|
||||
|
||||
def fetch_associated_domains(ident_code, ident_cc)
|
||||
cached = fetch_by_ident_and_cc(ident_code, ident_cc)
|
||||
if cached.blank?
|
||||
Domain.includes(:registrar, :registrant).where(contacts: {
|
||||
ident_type: 'priv',
|
||||
ident: ident_code,
|
||||
ident_country_code: ident_cc})
|
||||
else
|
||||
cached.associated_domains
|
||||
end
|
||||
fetch_by_ident_and_cc(ident_code, ident_cc).associated_domains
|
||||
end
|
||||
|
||||
def fetch_by_ident_and_cc(ident_code, ident_cc)
|
||||
cache = BusinessRegistryCache.find_by(ident: ident_code, ident_country_code: ident_cc)
|
||||
cache = BusinessRegistryCache.where(ident: ident_code, ident_country_code: ident_cc).first_or_initialize
|
||||
msg_start = "[Ariregister] #{ident_cc}-#{ident_code}:"
|
||||
|
||||
# fetch new data if cache is expired
|
||||
return cache if cache.present? && cache.retrieved_on > (Time.zone.now - Setting.days_to_keep_business_registry_cache.days)
|
||||
businesses = business_registry.associated_businesses(ident_code, ident_cc)
|
||||
unless businesses.nil?
|
||||
if cache.blank?
|
||||
cache = BusinessRegistryCache.new(businesses)
|
||||
else
|
||||
cache.update businesses
|
||||
end
|
||||
cache.save
|
||||
else
|
||||
cache = [] # expired data is forbidden
|
||||
if cache.retrieved_on && cache.retrieved_on > (Time.zone.now - Setting.days_to_keep_business_registry_cache.days)
|
||||
Rails.logger.info("#{msg_start} Info loaded from cache")
|
||||
return cache
|
||||
end
|
||||
|
||||
cache.attributes = business_registry.associated_businesses(ident_code, ident_cc)
|
||||
Rails.logger.info("#{msg_start} Info loaded from server")
|
||||
|
||||
cache.save
|
||||
cache
|
||||
end
|
||||
|
||||
def business_registry
|
||||
# TODO: can this be cached and shared?
|
||||
Soap::Arireg.new
|
||||
end
|
||||
|
||||
|
|
|
@ -95,22 +95,19 @@ module Soap
|
|||
'fyysilise_isiku_koodi_riik' => country_code_3(ident_cc)
|
||||
)
|
||||
content = extract response, :paringesindus_v4_response
|
||||
unless content.blank?
|
||||
if content[:ettevotjad].key? :item
|
||||
business_ident = items(content, :ettevotjad).map do |item|
|
||||
# debug helps users gather data for testing
|
||||
puts "#{item[:ariregistri_kood]}\t#{item[:arinimi]}\t#{item[:staatus]} #{item[:oiguslik_vorm]}\t" if @debug
|
||||
item[:ariregistri_kood]
|
||||
end
|
||||
{
|
||||
ident: ident,
|
||||
ident_country_code: ident_cc,
|
||||
# ident_type: 'priv',
|
||||
retrieved_on: Time.now,
|
||||
associated_businesses: business_ident
|
||||
}
|
||||
end
|
||||
if content.present? && content[:ettevotjad].key?(:item)
|
||||
business_ident = items(content, :ettevotjad).map{|item| item[:ariregistri_kood]}
|
||||
else
|
||||
business_ident = []
|
||||
end
|
||||
|
||||
{
|
||||
ident: ident,
|
||||
ident_country_code: ident_cc,
|
||||
# ident_type: 'priv',
|
||||
retrieved_on: Time.now,
|
||||
associated_businesses: business_ident
|
||||
}
|
||||
rescue Savon::SOAPFault => fault
|
||||
Rails.logger.error "#{fault} Äriregister arireg #{self.class.username} at #{self.class.host }"
|
||||
raise NotAvailableError.new(exception: fault)
|
||||
|
|
23
app/views/registrant/contacts/partials/_address.haml
Normal file
23
app/views/registrant/contacts/partials/_address.haml
Normal file
|
@ -0,0 +1,23 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t(:address)
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
- if @contact.org_name.present?
|
||||
%dt= t(:org_name)
|
||||
%dd= @contact.org_name
|
||||
|
||||
%dt= t(:street)
|
||||
%dd= @contact.street.to_s.gsub("\n", '<br>').html_safe
|
||||
|
||||
%dt= t(:city)
|
||||
%dd= @contact.city
|
||||
|
||||
%dt= t(:zip)
|
||||
%dd= @contact.zip
|
||||
|
||||
%dt= t(:state)
|
||||
%dd= @contact.state
|
||||
|
||||
%dt= t(:country)
|
||||
%dd= @contact.country
|
30
app/views/registrant/contacts/partials/_domains.haml
Normal file
30
app/views/registrant/contacts/partials/_domains.haml
Normal file
|
@ -0,0 +1,30 @@
|
|||
- domains = contact.all_domains(page: params[:domain_page], per: 20, params: params)
|
||||
#contacts.panel.panel-default
|
||||
.panel-heading
|
||||
.pull-left
|
||||
= t(:domains)
|
||||
.pull-right
|
||||
= form_tag request.path, method: :get do
|
||||
= select_tag :domain_filter, options_for_select(%w(Registrant AdminDomainContact TechDomainContact), selected: params[:domain_filter]),
|
||||
include_blank: true, class: 'form-control2 selectize2'
|
||||
%button.btn.btn-primary
|
||||
%span.glyphicon.glyphicon-search
|
||||
.clearfix
|
||||
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-3'}=custom_sort_link t(:domain_name), :name
|
||||
%th{class: 'col-xs-3'}=custom_sort_link t(:registrar), :registrar_name
|
||||
%th{class: 'col-xs-3'}=custom_sort_link t(:valid_to), :valid_to
|
||||
%th{class: 'col-xs-3'}= t(:roles)
|
||||
%tbody
|
||||
- domains.each do |x|
|
||||
%tr
|
||||
%td= link_to(x.name, [:registrant, x])
|
||||
%td= link_to(x.registrar, [:registrant, x.registrar])
|
||||
%td= l(x.valid_to, format: :short)
|
||||
%td= x.roles.join(", ")
|
||||
|
||||
= paginate domains, param_name: :domain_page
|
45
app/views/registrant/contacts/partials/_general.haml
Normal file
45
app/views/registrant/contacts/partials/_general.haml
Normal file
|
@ -0,0 +1,45 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t(:general)
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t(:id)
|
||||
%dd= @contact.code
|
||||
|
||||
%dt= t(:password)
|
||||
%dd
|
||||
= text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden'
|
||||
|
||||
%br
|
||||
|
||||
%dt= t(:ident)
|
||||
%dd= ident_for(@contact)
|
||||
|
||||
%dt= t(:email)
|
||||
%dd= @contact.email
|
||||
|
||||
%dt= t(:phone)
|
||||
%dd= @contact.phone
|
||||
|
||||
- if @contact.fax
|
||||
%dt= t(:fax)
|
||||
%dd= @contact.fax
|
||||
|
||||
%br
|
||||
|
||||
%dt= t(:created)
|
||||
%dd
|
||||
= l(@contact.created_at, format: :short)
|
||||
by
|
||||
= creator_link(@contact)
|
||||
|
||||
%dt= t(:updated)
|
||||
%dd
|
||||
= l(@contact.updated_at, format: :short)
|
||||
by
|
||||
= updator_link(@contact)
|
||||
|
||||
%dt= t(:registrar)
|
||||
%dd
|
||||
- if @contact.registrar.present?
|
||||
= link_to(@contact.registrar, registrant_registrar_path(@contact.registrar))
|
6
app/views/registrant/contacts/partials/_search.haml
Normal file
6
app/views/registrant/contacts/partials/_search.haml
Normal file
|
@ -0,0 +1,6 @@
|
|||
= search_form_for [:registrant, @q] do |f|
|
||||
= f.search_field :name_cont
|
||||
= f.submit do
|
||||
%span.glyphicon.glyphicon-search
|
||||
|
||||
|
21
app/views/registrant/contacts/partials/_statuses.haml
Normal file
21
app/views/registrant/contacts/partials/_statuses.haml
Normal file
|
@ -0,0 +1,21 @@
|
|||
- panel_class = contact.errors.messages[:statuses] ? 'panel-danger' : 'panel-default'
|
||||
#contact_statuses.panel{class: panel_class}
|
||||
.panel-heading.clearfix
|
||||
= t(:statuses)
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-6'}= t(:status)
|
||||
%th{class: 'col-xs-6'}= t(:notes)
|
||||
%tbody
|
||||
- contact.statuses.each do |status|
|
||||
%tr
|
||||
%td= status
|
||||
%td= contact.status_notes[status]
|
||||
|
||||
- if contact.errors.messages[:statuses]
|
||||
%tfoot
|
||||
- @domain.errors.messages[:statuses].each do |s|
|
||||
%tr
|
||||
%td{colspan: 4}= s
|
12
app/views/registrant/contacts/show.haml
Normal file
12
app/views/registrant/contacts/show.haml
Normal file
|
@ -0,0 +1,12 @@
|
|||
- content_for :actions do
|
||||
= render 'shared/title', name: @contact.name
|
||||
|
||||
.row
|
||||
.col-md-6= render 'registrant/contacts/partials/general'
|
||||
.col-md-6= render 'registrant/contacts/partials/address'
|
||||
.row
|
||||
.col-md-12= render 'registrant/contacts/partials/statuses', contact: @contact
|
||||
.row
|
||||
.col-md-12= render 'registrant/contacts/partials/domains', contact: @contact
|
||||
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
%tbody
|
||||
- @domain.admin_contacts.each do |ac|
|
||||
%tr
|
||||
%td= link_to(ac, admin_contact_path(ac))
|
||||
%td= link_to(ac, registrant_contact_path(ac))
|
||||
%td= ac.code
|
||||
%td= ac.email
|
||||
- if @domain.errors.messages[:admin_contacts]
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
%dd= l(@domain.registered_at)
|
||||
|
||||
%dt= t(:registrar)
|
||||
%dd= link_to(@domain.registrar, admin_registrar_path(@domain.registrar))
|
||||
%dd= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar))
|
||||
|
||||
%dt= t(:authinfo_pw)
|
||||
%dd
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
%tbody
|
||||
- @domain.keyrelays.includes([:requester, :accepter]).order(pa_date: :desc).each do |x|
|
||||
%tr
|
||||
%td= link_to(x.pa_date, [:admin, x])
|
||||
%td= link_to(x.pa_date, [:registrar, x])
|
||||
%td= x.expiry
|
||||
%td= link_to(x.requester, [:admin, x.requester])
|
||||
%td= link_to(x.accepter, [:admin, x.accepter])
|
||||
%td= link_to(x.requester, [:registrar, x.requester])
|
||||
%td= link_to(x.accepter, [:registrar, x.accepter])
|
||||
%td= x.status
|
||||
|
|
|
@ -10,5 +10,5 @@
|
|||
%tbody
|
||||
- legal_documents.each do |x|
|
||||
%tr
|
||||
%td= link_to(x.created_at, [:admin, x])
|
||||
%td= link_to(x.created_at, [:registrar, x])
|
||||
%td= x.document_type
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t(:name)
|
||||
%dd= link_to(@domain.registrant, [:admin, @domain.registrant])
|
||||
%dd= link_to(@domain.registrant, [:registrar, @domain.registrant])
|
||||
|
||||
%dt= t(:id)
|
||||
%dd= @domain.registrant_code
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
%tbody
|
||||
- @domain.tech_contacts.each do |tc|
|
||||
%tr
|
||||
%td= link_to(tc, admin_contact_path(tc))
|
||||
%td= link_to(tc, registrant_contact_path(tc))
|
||||
%td= tc.code
|
||||
%td= tc.email
|
||||
- if @domain.errors.messages[:tech_contacts]
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
- content_for :actions do
|
||||
-#= link_to(t(:history), admin_domain_domain_versions_path(@domain.id), method: :get, class: 'btn btn-primary')
|
||||
|
||||
= render 'shared/title', name: @domain.name
|
||||
= render 'shared/title', name: @domain.name
|
||||
|
||||
.row
|
||||
.col-md-6= render 'registrant/domains/partials/general'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
.row
|
||||
.col-md-12
|
||||
= search_form_for [:admin, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f|
|
||||
= search_form_for [:registrar, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f|
|
||||
.row
|
||||
.col-md-3
|
||||
.form-group
|
||||
|
@ -91,13 +91,13 @@
|
|||
%tbody
|
||||
- @contacts.each do |contact|
|
||||
%tr
|
||||
%td= link_to(contact, admin_contact_path(contact))
|
||||
%td= link_to(contact, registrar_contact_path(contact))
|
||||
%td= contact.code
|
||||
%td= ident_for(contact)
|
||||
%td= l(contact.created_at, format: :short)
|
||||
%td
|
||||
- if contact.registrar
|
||||
= link_to(contact.registrar, admin_registrar_path(contact.registrar))
|
||||
= link_to(contact.registrar, registrar_registrar_path(contact.registrar))
|
||||
|
||||
.row
|
||||
.col-md-6
|
||||
|
@ -109,4 +109,4 @@
|
|||
:coffee
|
||||
$(".js-reset-form").on "click", (e) ->
|
||||
e.preventDefault();
|
||||
window.location = "#{admin_contacts_path}"
|
||||
window.location = "#{registrar_contacts_path}"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
- content_for :actions do
|
||||
= link_to(t(:new), new_admin_registrar_path, class: 'btn btn-primary')
|
||||
= render 'shared/title', name: t(:registrars)
|
||||
= render 'shared/title', name: t(:registrars)
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
|
@ -15,7 +14,7 @@
|
|||
%tbody
|
||||
- @registrars.each do |x|
|
||||
%tr
|
||||
%td= link_to(x, [:admin, x])
|
||||
%td= link_to(x, [:registrar, x])
|
||||
%td= x.reg_no
|
||||
.row
|
||||
.col-md-12
|
||||
|
|
|
@ -156,6 +156,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :registrants
|
||||
resources :contacts
|
||||
|
||||
resources :whois
|
||||
# resources :contacts do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue