mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Merge pull request #107 from internetee/105842700-registrants_portal
105842700 registrants portal
This commit is contained in:
commit
71e3db611b
18 changed files with 126 additions and 242 deletions
|
@ -1,8 +1,26 @@
|
|||
class Registrant::ContactsController < RegistrantController
|
||||
|
||||
helper_method :domain_ids
|
||||
def show
|
||||
@contact = Contact.find(params[:id])
|
||||
@contact = Contact.where(id: contacts).find_by(id: params[:id])
|
||||
@current_user = current_user
|
||||
|
||||
authorize! :read, @contact
|
||||
@contact.valid?
|
||||
end
|
||||
|
||||
def contacts
|
||||
begin
|
||||
DomainContact.where(domain_id: domain_ids).pluck(:contact_id) | Domain.where(id: domain_ids).pluck(:registrant_id)
|
||||
rescue Soap::Arireg::NotAvailableError => error
|
||||
flash[:notice] = I18n.t(error.json[:message])
|
||||
Rails.logger.fatal("[EXCEPTION] #{error.to_s}")
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def domain_ids
|
||||
@domain_ids ||= begin
|
||||
ident_cc, ident = @current_user.registrant_ident.to_s.split '-'
|
||||
BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_domain_ids
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,15 +11,28 @@ class Registrant::DomainsController < RegistrantController
|
|||
end
|
||||
|
||||
def show
|
||||
@domain = Domain.find(params[:id])
|
||||
if !(domains.include?(@domain) || @domain.valid?)
|
||||
redirect_to registrant_domains_path
|
||||
end
|
||||
@domain = domains.find(params[:id])
|
||||
authorize! :read, @domain
|
||||
end
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find(params[:id])
|
||||
@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?
|
||||
|
||||
@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')
|
||||
redirect_to registrant_domain_path(dom.id)
|
||||
end
|
||||
end
|
||||
|
||||
def download_list
|
||||
|
@ -61,4 +74,13 @@ class Registrant::DomainsController < RegistrantController
|
|||
yield
|
||||
params[:q][:valid_to_lteq] = ca_cache
|
||||
end
|
||||
|
||||
def get_confirm_path(statuses)
|
||||
if statuses.include?(DomainStatus::PENDING_UPDATE)
|
||||
"#{ENV['registrant_url']}/registrant/domain_update_confirms"
|
||||
elsif statuses.include?(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||
"#{ENV['registrant_url']}/registrant/domain_delete_confirms"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,8 +0,0 @@
|
|||
class Registrant::RegistrantsController < RegistrantController
|
||||
|
||||
def show
|
||||
@contact = Registrant.find(params[:id])
|
||||
authorize! :read, @contact
|
||||
@contact.valid?
|
||||
end
|
||||
end
|
|
@ -22,17 +22,26 @@ class BusinessRegistryCache < ActiveRecord::Base
|
|||
|
||||
# 1. load domains by business
|
||||
# 2. load domains by person
|
||||
def associated_domains
|
||||
domains = []
|
||||
|
||||
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)
|
||||
|
||||
unless contact_ids.blank?
|
||||
domains = DomainContact.distinct.where(contact_id: contact_ids).pluck(:domain_id)
|
||||
contact_ids
|
||||
end
|
||||
|
||||
Domain.includes(:registrar, :registrant).where(id: domains)
|
||||
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
|
||||
end
|
||||
|
||||
def associated_domains
|
||||
Domain.includes(:registrar, :registrant).where(id: associated_domain_ids)
|
||||
end
|
||||
|
||||
class << self
|
||||
|
|
|
@ -415,7 +415,10 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
|
||||
# fetch domains
|
||||
domains = Domain.where("domains.id IN (#{filter_sql})").includes(:registrar).page(page).per(per)
|
||||
domains = Domain.where("domains.id IN (#{filter_sql})")
|
||||
domains = domains.where("domains.id" => params[:leave_domains]) if params[:leave_domains]
|
||||
domains = domains.includes(:registrar).page(page).per(per)
|
||||
|
||||
if sorts.first == "registrar_name".freeze
|
||||
# using small rails hack to generate outer join
|
||||
domains = domains.includes(:registrar).where.not(registrars: {id: nil}).order("registrars.name #{order} NULLS LAST")
|
||||
|
@ -434,6 +437,30 @@ 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
|
||||
|
|
|
@ -869,6 +869,7 @@ class Epp::Domain < Domain
|
|||
ld = parsed_frame.css('legalDocument').first
|
||||
return nil unless ld
|
||||
return nil if ld.text.starts_with?(ENV['legal_documents_dir']) # escape reloading
|
||||
return nil if ld.text.starts_with?('/home/') # escape reloading
|
||||
|
||||
{
|
||||
body: ld.text,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- domains = contact.all_domains(page: params[:domain_page], per: 20, params: params)
|
||||
- domains = contact.all_domains(page: params[:domain_page], per: 20, params: params.merge(leave_domains: domain_ids))
|
||||
#contacts.panel.panel-default
|
||||
.panel-heading
|
||||
.pull-left
|
||||
|
@ -18,7 +18,7 @@
|
|||
%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)
|
||||
%th{class: 'col-xs-3'}=custom_sort_link t(:roles), :roles
|
||||
%tbody
|
||||
- domains.each do |x|
|
||||
%tr
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
%dt= t(:id)
|
||||
%dd= @contact.code
|
||||
|
||||
%dt= t(:name)
|
||||
%dd= @contact.name
|
||||
|
||||
%dt= t(:password)
|
||||
%dd
|
||||
= text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden'
|
||||
|
@ -31,13 +34,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
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
- content_for :actions do
|
||||
= render 'shared/title', name: @contact.name
|
||||
|
||||
.row
|
||||
|
|
13
app/views/registrant/domains/domain_verification_url.haml
Normal file
13
app/views/registrant/domains/domain_verification_url.haml
Normal file
|
@ -0,0 +1,13 @@
|
|||
- content_for :actions do
|
||||
= render 'shared/title', name: @domain.name
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t(:personal_domain_verification_url)
|
||||
.panel-body
|
||||
.input-group.input-group-lg
|
||||
%span#sizing-addon1.input-group-addon.glyphicon.glyphicon-link
|
||||
%input.form-control{"aria-describedby" => "sizing-addon1", type: "text", value: @verification_url}
|
||||
|
|
@ -66,10 +66,7 @@
|
|||
- @domains.each do |x|
|
||||
%tr
|
||||
%td= link_to(x, registrant_domain_path(x))
|
||||
%td
|
||||
- if x.registrant
|
||||
= link_to(x.registrant, [:registrant, x.registrant]) if x.registrant
|
||||
|
||||
%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
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t(:name)
|
||||
%dd= link_to(@domain.registrant, [:registrar, @domain.registrant])
|
||||
%dd= link_to(@domain.registrant.name, registrant_contact_path(@domain.registrant))
|
||||
|
||||
%dt= t(:id)
|
||||
%dd= @domain.registrant_code
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
- @domain.statuses.each do |status|
|
||||
%tr
|
||||
%td
|
||||
- if @domain.pending_json.present? && [DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE].include?(status)
|
||||
= link_to status, admin_domain_domain_versions_path(@domain.id)
|
||||
- if [DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE_CONFIRMATION].include?(status) && @domain.pending_json.present?
|
||||
= link_to(status, domain_verification_url_registrant_domain_url(@domain.id))
|
||||
- else
|
||||
= status
|
||||
%td= @domain.status_notes[status]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
- content_for :actions do
|
||||
= 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
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
= render 'shared/title', name: t(:contacts)
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
= search_form_for [:registrar, @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(:id)
|
||||
= f.search_field :code_eq, class: 'form-control', placeholder: t(:id)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:ident)
|
||||
= f.search_field :ident_matches, class: 'form-control', placeholder: t(:ident)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= label_tag t(:ident_type)
|
||||
= select_tag '[q][ident_type_eq]', options_for_select(Contact::IDENT_TYPES, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' }
|
||||
.row
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:email)
|
||||
= f.search_field :email_matches, class: 'form-control', placeholder: t(:email)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= label_tag t(:country)
|
||||
= select_tag '[q][country_code_eq]', SortedCountry.all_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' }
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:is_registrant)
|
||||
%div
|
||||
= f.check_box :registrant_domains_id_not_null
|
||||
.col-md-3
|
||||
.form-group
|
||||
= label_tag t(:contact_type)
|
||||
= select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' }
|
||||
.row
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:registrar)
|
||||
= f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:created_at_from)
|
||||
= f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control datepicker', placeholder: t(:created_at_from)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:created_at_until)
|
||||
= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:created_at_until)
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:updated_at)
|
||||
= f.search_field :updated_at_gteq, value: params[:q][:updated_at_gteq], class: 'form-control datepicker', placeholder: t(:updated_at)
|
||||
.row
|
||||
.col-md-6
|
||||
.form-group
|
||||
= label_tag t(:status)
|
||||
= select_tag :statuses_contains, options_for_select(Contact::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' }
|
||||
.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
|
||||
|
||||
%span.glyphicon.glyphicon-search
|
||||
|
||||
%button.btn.btn-default.js-reset-form
|
||||
= t(:clear_fields)
|
||||
%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', t(:name))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'code', t(:id))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'ident', t(:ident))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'email', t(:created_at))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'registrar_name', t(:registrar))
|
||||
%tbody
|
||||
- @contacts.each do |contact|
|
||||
%tr
|
||||
%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, registrar_registrar_path(contact.registrar))
|
||||
|
||||
.row
|
||||
.col-md-6
|
||||
= paginate @contacts
|
||||
.col-md-6.text-right
|
||||
.pagination
|
||||
= t(:result_count, count: @contacts.total_count)
|
||||
|
||||
:coffee
|
||||
$(".js-reset-form").on "click", (e) ->
|
||||
e.preventDefault();
|
||||
window.location = "#{registrar_contacts_path}"
|
|
@ -1,75 +0,0 @@
|
|||
= render 'shared/title', name: @contact.name
|
||||
|
||||
.row
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t(:general)
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t(:id)
|
||||
%dd= @contact.code
|
||||
|
||||
%dt= t(:authinfo_pw)
|
||||
%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)) if @contact.registrar
|
||||
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t(:contact)
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%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
|
|
@ -932,6 +932,8 @@ en:
|
|||
if_auth_info_is_left_empty_it_will_be_auto_generated: 'If auth info is left empty, it will be auto generated.'
|
||||
each_domain_name_must_end_with_colon_sign: 'Each domain name must end with colon (:) sign.'
|
||||
expiration_remind_subject: 'The %{name} domain has expired'
|
||||
personal_domain_verification_url: 'Personal domain verification url'
|
||||
available_verification_url_not_found: 'Available verification url not found, for domain.'
|
||||
contact_already_associated_with_the_domain: 'Object association prohibits operation, contact already associated with the domain'
|
||||
add_reserved_domain: 'Add domain to reserved list'
|
||||
add_blocked_domain: 'Add domain to blocked list'
|
||||
|
|
|
@ -107,6 +107,11 @@ Rails.application.routes.draw do
|
|||
collection do
|
||||
get :download_list
|
||||
end
|
||||
|
||||
member do
|
||||
get 'domain_verification_url'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# resources :invoices do
|
||||
|
@ -155,28 +160,11 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :registrants
|
||||
resources :contacts
|
||||
|
||||
resources :whois
|
||||
# resources :contacts do
|
||||
# member do
|
||||
# get 'delete'
|
||||
# end
|
||||
|
||||
# collection do
|
||||
# get 'check'
|
||||
# end
|
||||
# end
|
||||
|
||||
# resource :poll do
|
||||
# collection do
|
||||
# post 'confirm_keyrelay'
|
||||
# post 'confirm_transfer'
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
# ADMIN ROUTES
|
||||
namespace :admin do
|
||||
resources :keyrelays
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue