mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Story#105314040 In admin contacts show all domains. Roles are missing
This commit is contained in:
parent
dc6b9ac924
commit
af4e609a6d
3 changed files with 30 additions and 5 deletions
|
@ -45,7 +45,7 @@ class Admin::ContactsController < AdminController
|
|||
private
|
||||
|
||||
def set_contact
|
||||
@contact = Contact.includes(domains: :registrar).find(params[:id])
|
||||
@contact = Contact.find(params[:id])
|
||||
end
|
||||
|
||||
def contact_params
|
||||
|
|
|
@ -349,6 +349,26 @@ class Contact < ActiveRecord::Base
|
|||
"#{code} #{name}"
|
||||
end
|
||||
|
||||
|
||||
# what we can do load firstly by registrant
|
||||
# if total is smaller than needed, the load more
|
||||
# we also need to sort by valid_to
|
||||
def all_domains(page: nil, per: nil)
|
||||
sql = %Q{id IN (
|
||||
select domain_id from domain_contacts where contact_id=#{id}
|
||||
UNION
|
||||
select id from domains where registrant_id=#{id}
|
||||
)}
|
||||
|
||||
|
||||
# sql = Domain.joins(:domain_contacts).where(domain_contacts: {contact_id: id}).select("#{Domain.table_name}.*".freeze, "'domain_contacts' AS style").
|
||||
# union(registrant_domains.select("#{Domain.table_name}.*".freeze, "'registrant_domains' AS style")).to_sql
|
||||
# merged_sql = "select #{Domain.column_names.join(',')}, array_agg (t.style) over (partition by t.id) style from (#{sql} limit #{per.to_i}) t"
|
||||
domains = Domain.where(sql).order("valid_to DESC NULLS LAST").includes(:registrar).page(page).per(per)
|
||||
|
||||
domains
|
||||
end
|
||||
|
||||
def set_linked
|
||||
statuses << LINKED if statuses.detect { |s| s == LINKED }.blank?
|
||||
end
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
- domains = @contact.all_domains(page: params[:domain_page], per: 20)
|
||||
#contacts.panel.panel-default
|
||||
.panel-heading= t(:domains)
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-bordered.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-4'}= t(:domain_name)
|
||||
%th{class: 'col-xs-4'}= t(:registrar)
|
||||
%th{class: 'col-xs-4'}= t(:valid_to)
|
||||
%th{class: 'col-xs-3'}= t(:domain_name)
|
||||
%th{class: 'col-xs-3'}= t(:registrar)
|
||||
%th{class: 'col-xs-3'}= t(:valid_to)
|
||||
%th{class: 'col-xs-3'}= t(:roles)
|
||||
%tbody
|
||||
- @contact.registrant_domains.each do |x|
|
||||
- domains.each do |x|
|
||||
%tr
|
||||
%td= link_to(x.name, [:admin, x])
|
||||
%td= link_to(x.registrar, [:admin, x.registrar])
|
||||
%td= l(x.valid_to, format: :short)
|
||||
%td= t(:registrar)
|
||||
|
||||
= paginate domains, param_name: :domain_page
|
Loading…
Add table
Add a link
Reference in a new issue