mirror of
https://github.com/internetee/registry.git
synced 2025-05-20 11:19:39 +02:00
Merge branch '105842700-registrants_portal' into staging
This commit is contained in:
commit
5a9f4125ef
7 changed files with 97 additions and 11 deletions
|
@ -1,14 +1,15 @@
|
|||
class Registrant::ContactsController < RegistrantController
|
||||
|
||||
def show
|
||||
@contact = Contact.where(id: contacts).find(params[:id])
|
||||
@contact = Contact.where(id: contacts).find_by(id: params[:id])
|
||||
@current_user = current_user
|
||||
authorize! :read, @contact
|
||||
end
|
||||
|
||||
def contacts
|
||||
ident_cc, ident = @current_user.registrant_ident.to_s.split '-'
|
||||
begin
|
||||
BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_contacts
|
||||
DomainContact.where(domain_id: BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_domain_ids).pluck(:contact_id)
|
||||
rescue Soap::Arireg::NotAvailableError => error
|
||||
flash[:notice] = I18n.t(error.json[:message])
|
||||
Rails.logger.fatal("[EXCEPTION] #{error.to_s}")
|
||||
|
|
|
@ -28,16 +28,20 @@ class BusinessRegistryCache < ActiveRecord::Base
|
|||
contact_ids
|
||||
end
|
||||
|
||||
def associated_domains
|
||||
domains = []
|
||||
def associated_domain_ids
|
||||
domain_ids = []
|
||||
|
||||
contact_ids = associated_contacts
|
||||
|
||||
unless contact_ids.blank?
|
||||
domains = DomainContact.distinct.where(contact_id: contact_ids).pluck(:domain_id)
|
||||
domain_ids = DomainContact.distinct.where(contact_id: contact_ids).pluck(:domain_id)
|
||||
end
|
||||
|
||||
Domain.includes(:registrar, :registrant).where(id: domains)
|
||||
domain_ids
|
||||
end
|
||||
|
||||
def associated_domains
|
||||
Domain.includes(:registrar, :registrant).where(id: associated_domain_ids)
|
||||
end
|
||||
|
||||
class << self
|
||||
|
|
|
@ -438,6 +438,31 @@ class Contact < ActiveRecord::Base
|
|||
domains
|
||||
end
|
||||
|
||||
def all_registrant_domains(page: nil, per: nil, params: {}, registrant: nil)
|
||||
|
||||
if registrant
|
||||
sorts = params.fetch(:sort, {}).first || []
|
||||
sort = Domain.column_names.include?(sorts.first) ? sorts.first : "valid_to"
|
||||
order = {"asc"=>"desc", "desc"=>"asc"}[sorts.second] || "desc"
|
||||
|
||||
domain_ids = DomainContact.distinct.where(contact_id: registrant.id).pluck(:domain_id)
|
||||
|
||||
domains = Domain.where(id: domain_ids).includes(:registrar).page(page).per(per)
|
||||
if sorts.first == "registrar_name".freeze
|
||||
domains = domains.includes(:registrar).where.not(registrars: {id: nil}).order("registrars.name #{order} NULLS LAST")
|
||||
else
|
||||
domains = domains.order("#{sort} #{order} NULLS LAST")
|
||||
end
|
||||
|
||||
domain_c = Hash.new([])
|
||||
registrant_domains.where(id: domains.map(&:id)).each{|d| domain_c[d.id] |= ["Registrant".freeze] }
|
||||
DomainContact.where(contact_id: id, domain_id: domains.map(&:id)).each{|d| domain_c[d.domain_id] |= [d.type] }
|
||||
domains.each{|d| d.roles = domain_c[d.id].uniq}
|
||||
domains
|
||||
end
|
||||
[]
|
||||
end
|
||||
|
||||
def set_linked
|
||||
statuses << LINKED if statuses.detect { |s| s == LINKED }.blank?
|
||||
end
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
%dd
|
||||
= l(@contact.created_at, format: :short)
|
||||
by
|
||||
= creator_link(@contact)
|
||||
= @contact.name
|
||||
|
||||
%dt= t(:updated)
|
||||
%dd
|
||||
= l(@contact.updated_at, format: :short)
|
||||
by
|
||||
= updator_link(@contact)
|
||||
= @contact.name
|
||||
|
||||
%dt= t(:registrar)
|
||||
%dd
|
||||
|
|
30
app/views/registrant/registrants/partials/_domains.haml
Normal file
30
app/views/registrant/registrants/partials/_domains.haml
Normal file
|
@ -0,0 +1,30 @@
|
|||
- domains = contact.all_registrant_domains(page: params[:domain_page], per: 20, params: params, current_user: current_user)
|
||||
#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
|
21
app/views/registrant/registrants/partials/_statuses.haml
Normal file
21
app/views/registrant/registrants/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
|
|
@ -35,13 +35,13 @@
|
|||
%dd
|
||||
= l(@contact.created_at, format: :short)
|
||||
by
|
||||
= creator_link(@contact)
|
||||
= @contact.name
|
||||
|
||||
%dt= t(:updated)
|
||||
%dd
|
||||
= l(@contact.updated_at, format: :short)
|
||||
by
|
||||
= updator_link(@contact)
|
||||
= @contact.name
|
||||
|
||||
%dt= t(:registrar)
|
||||
%dd
|
||||
|
@ -72,4 +72,9 @@
|
|||
%dd= @contact.state
|
||||
|
||||
%dt= t(:country)
|
||||
%dd= @contact.country
|
||||
%dd= @contact.country
|
||||
|
||||
.row
|
||||
.col-md-12= render 'registrant/registrants/partials/statuses', contact: @contact
|
||||
.row
|
||||
.col-md-12= render 'registrant/registrants/partials/domains', contact: @contact
|
Loading…
Add table
Add a link
Reference in a new issue