Merge branch 'master' into registry-887-revoke-certificate-before-removing-it

This commit is contained in:
Maciej Szlosarczyk 2018-09-20 16:08:18 +03:00
commit 24b87d8592
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
70 changed files with 611 additions and 449 deletions

View file

@ -1,6 +1,7 @@
html
position: relative
min-height: 100%
overflow-y: scroll
body
padding-bottom: 130px
@ -30,9 +31,6 @@ h1, h2, h3, h4
color: white !important
background-size: 100%
.semifooter
padding: 42px 0 80px 0
.confirmation
padding: 40px 0 20px 0
.column-keys

View file

@ -6,7 +6,8 @@ module Admin
domain.transaction do
domain.schedule_force_delete
domain.registrar.messages.create!(body: t('force_delete_set_on_domain', domain_name: domain.name))
domain.registrar.notifications.create!(text: t('force_delete_set_on_domain',
domain_name: domain.name))
if notify_by_email?
DomainDeleteMailer.forced(domain: domain,

View file

@ -9,12 +9,12 @@ class Epp::PollsController < EppController
private
def req_poll
@message = current_user.queued_messages.order('created_at DESC').take
@notification = current_user.unread_notifications.order('created_at DESC').take
render_epp_response 'epp/poll/poll_no_messages' and return unless @message
if @message.attached_obj_type && @message.attached_obj_id
render_epp_response 'epp/poll/poll_no_messages' and return unless @notification
if @notification.attached_obj_type && @notification.attached_obj_id
begin
@object = Object.const_get(@message.attached_obj_type).find(@message.attached_obj_id)
@object = Object.const_get(@notification.attached_obj_type).find(@notification.attached_obj_id)
rescue => problem
# the data model might be inconsistent; or ...
# this could happen if the registrar does not dequeue messages, and then the domain was deleted
@ -28,7 +28,7 @@ class Epp::PollsController < EppController
end
end
if @message.attached_obj_type == 'Keyrelay'
if @notification.attached_obj_type == 'Keyrelay'
render_epp_response 'epp/poll/poll_keyrelay'
else
render_epp_response 'epp/poll/poll_req'
@ -36,9 +36,9 @@ class Epp::PollsController < EppController
end
def ack_poll
@message = current_user.queued_messages.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
@notification = current_user.unread_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
unless @message
unless @notification
epp_errors << {
code: '2303',
msg: I18n.t('message_was_not_found'),
@ -47,7 +47,7 @@ class Epp::PollsController < EppController
handle_errors and return
end
handle_errors(@message) and return unless @message.dequeue
handle_errors(@notification) and return unless @notification.mark_as_read
render_epp_response 'epp/poll/poll_ack'
end
@ -56,6 +56,6 @@ class Epp::PollsController < EppController
end
def resource
@message
@notification
end
end

View file

@ -1,5 +1,6 @@
class Registrant::ContactsController < RegistrantController
helper_method :domain_ids
helper_method :domain
def show
@contact = Contact.where(id: contacts).find_by(id: params[:id])
@ -25,4 +26,19 @@ class Registrant::ContactsController < RegistrantController
BusinessRegistryCache.fetch_by_ident_and_cc(ident, ident_cc).associated_domain_ids
end
end
end
def domain
current_user_domains.find(params[:domain_id])
end
def current_user_domains
ident_cc, ident = current_registrant_user.registrant_ident.split '-'
begin
BusinessRegistryCache.fetch_associated_domains ident, ident_cc
rescue Soap::Arireg::NotAvailableError => error
flash[:notice] = I18n.t(error.json[:message])
Rails.logger.fatal("[EXCEPTION] #{error.to_s}")
current_registrant_user.domains
end
end
end

View file

@ -3,7 +3,8 @@ class Registrar
protect_from_forgery except: [:back, :callback]
skip_authorization_check # actually anyone can pay, no problems at all
skip_before_action :authenticate_user!, :check_ip_restriction, only: [:back, :callback]
skip_before_action :authenticate_registrar_user!, :check_ip_restriction,
only: [:back, :callback]
before_action :check_supported_payment_method
def pay

View file

@ -7,13 +7,13 @@ class DomainDeleteConfirmJob < Que::Job
case action
when RegistrantVerification::CONFIRMED
domain.poll_message!(:poll_pending_delete_confirmed_by_registrant)
domain.notify_registrar(:poll_pending_delete_confirmed_by_registrant)
domain.apply_pending_delete!
raise_errors!(domain)
when RegistrantVerification::REJECTED
domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
domain.poll_message!(:poll_pending_delete_rejected_by_registrant)
domain.notify_registrar(:poll_pending_delete_rejected_by_registrant)
domain.cancel_pending_delete
domain.save(validate: false)

View file

@ -8,8 +8,8 @@ class DomainDeleteJob < Que::Job
domain.destroy
bye_bye = domain.versions.last
domain.registrar.messages.create!(
body: "#{I18n.t(:domain_deleted)}: #{domain.name}",
domain.registrar.notifications.create!(
text: "#{I18n.t(:domain_deleted)}: #{domain.name}",
attached_obj_id: bye_bye.id,
attached_obj_type: bye_bye.class.to_s
)

View file

@ -8,7 +8,7 @@ class DomainUpdateConfirmJob < Que::Job
case action
when RegistrantVerification::CONFIRMED
old_registrant = domain.registrant
domain.poll_message!(:poll_pending_update_confirmed_by_registrant)
domain.notify_registrar(:poll_pending_update_confirmed_by_registrant)
raise_errors!(domain)
domain.apply_pending_update!
@ -22,7 +22,7 @@ class DomainUpdateConfirmJob < Que::Job
registrar: domain.registrar,
registrant: domain.registrant).deliver_now
domain.poll_message!(:poll_pending_update_rejected_by_registrant)
domain.notify_registrar(:poll_pending_update_rejected_by_registrant)
domain.preclean_pendings
domain.clean_pendings!

View file

@ -5,7 +5,7 @@ class InvoiceMailer < ApplicationMailer
@invoice = Invoice.find_by(id: invoice_id)
billing_email ||= @invoice.billing_email
return unless @invoice
return if whitelist_blocked?(@invoice.billing_email)
return if whitelist_blocked?(billing_email)
kit = PDFKit.new(html)
pdf = kit.to_pdf

View file

@ -1,5 +1,3 @@
require 'csv'
class AccountActivity < ActiveRecord::Base
include Versions
belongs_to :account, required: true

View file

@ -81,8 +81,8 @@ class ApiUser < User
username
end
def queued_messages
registrar.messages.queued
def unread_notifications
registrar.notifications.unread
end
def registrar_pki_ok?(crt, cn)

View file

@ -265,9 +265,9 @@ class Domain < ActiveRecord::Base
true
end
def poll_message!(message_key)
registrar.messages.create!(
body: "#{I18n.t(message_key)}: #{name}",
def notify_registrar(message_key)
registrar.notifications.create!(
text: "#{I18n.t(message_key)}: #{name}",
attached_obj_id: id,
attached_obj_type: self.class.to_s
)

View file

@ -73,8 +73,8 @@ class DomainTransfer < ActiveRecord::Base
old_contacts_codes = domain.contacts.pluck(:code).sort.uniq.join(', ')
old_registrant_code = domain.registrant.code
old_registrar.messages.create!(
body: I18n.t('messages.texts.domain_transfer',
old_registrar.notifications.create!(
text: I18n.t('notifications.texts.domain_transfer',
domain_name: domain.name,
old_contacts_codes: old_contacts_codes,
old_registrant_code: old_registrant_code),

View file

@ -625,8 +625,8 @@ class Epp::Domain < Domain
)
if dt.pending?
registrar.messages.create!(
body: I18n.t('transfer_requested'),
registrar.notifications.create!(
text: I18n.t('transfer_requested'),
attached_obj_id: dt.id,
attached_obj_type: dt.class.to_s
)
@ -727,8 +727,8 @@ class Epp::Domain < Domain
return false unless valid?
registrar.messages.create!(
body: 'Key Relay action completed successfully.',
registrar.notifications.create!(
text: 'Key Relay action completed successfully.',
attached_obj_type: kr.class.to_s,
attached_obj_id: kr.id
)

View file

@ -1,19 +0,0 @@
class Message < ActiveRecord::Base
include Versions # version/message_version.rb
belongs_to :registrar, required: true
before_create -> { self.queued = true }
scope :queued, -> { where(queued: true) }
validates :body, presence: true
def dequeue
self.queued = false
save
end
def name
"-"
end
end

View file

@ -0,0 +1,31 @@
class Notification < ActiveRecord::Base
include Versions # version/notification_version.rb
belongs_to :registrar
scope :unread, -> { where(read: false) }
validates :text, presence: true
after_initialize :set_defaults
def mark_as_read
raise 'Read notification cannot be marked as read again' if read?
self.read = true
save
end
def unread?
!read?
end
# Needed for EPP log
def name
"-"
end
private
def set_defaults
self.read = false if read.nil?
end
end

View file

@ -4,7 +4,7 @@ class Registrar < ActiveRecord::Base
has_many :domains, dependent: :restrict_with_error
has_many :contacts, dependent: :restrict_with_error
has_many :api_users, dependent: :restrict_with_error
has_many :messages
has_many :notifications
has_many :invoices, foreign_key: 'buyer_id'
has_many :accounts, dependent: :destroy
has_many :nameservers, through: :domains

View file

@ -1,5 +0,0 @@
class MessageVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_messages
self.sequence_name = :log_messages_id_seq
end

View file

@ -0,0 +1,5 @@
class NotificationVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_notifications
self.sequence_name = :log_notifications_id_seq
end

View file

@ -16,9 +16,6 @@
<dt><%= t(:contact_email) %></dt>
<dd><%= @registrar.email %></dd>
<dt><%= Registrar.human_attribute_name :billing_email %></dt>
<dd><%= @registrar.billing_email %></dd>
</dl>
</div>
</div>

View file

@ -1,4 +0,0 @@
builder.tag!('domain:delData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
builder.tag!('domain:name', bye_bye.object['name'])
builder.tag!('domain:exDate', bye_bye.created_at)
end

View file

@ -4,7 +4,7 @@ xml.epp_head do
xml.msg 'Command completed successfully'
end
xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id)
xml.tag!('msgQ', 'count' => current_user.unread_notifications.count, 'id' => @notification.id)
render('epp/shared/trID', builder: xml)
end

View file

@ -10,9 +10,9 @@ xml.epp(
xml.msg 'Command completed successfully; ack to dequeue'
end
xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) do
xml.qDate @message.created_at.try(:iso8601)
xml.msg @message.body
xml.tag!('msgQ', 'count' => current_user.unread_notifications.count, 'id' => @notification.id) do
xml.qDate @notification.created_at.try(:iso8601)
xml.msg @notification.text
end
xml.resData do

View file

@ -4,12 +4,12 @@ xml.epp_head do
xml.msg 'Command completed successfully; ack to dequeue'
end
xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) do
xml.qDate @message.created_at.utc.xmlschema
xml.msg @message.body
xml.tag!('msgQ', 'count' => current_user.unread_notifications.count, 'id' => @notification.id) do
xml.qDate @notification.created_at.utc.xmlschema
xml.msg @notification.text
end
if @message.attached_obj_type == 'DomainTransfer'
if @notification.attached_obj_type == 'DomainTransfer'
xml.resData do
xml << render('epp/domains/partials/transfer', builder: xml, dt: @object)
end if @object

View file

@ -1,3 +1,9 @@
<ol class="breadcrumb">
<li><%= link_to t('registrant.domains.index.header'), registrant_domains_path %></li>
<li><%= link_to domain, registrant_domain_path(domain) %></li>
<li><%= t 'registrant.contacts.contact_index' %></li>
</ol>
<div class="page-header">
<h1><%= @contact.name %></h1>
</div>

View file

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

View file

@ -76,7 +76,7 @@
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed">
<table class="table table-hover table-bordered table-condensed domains">
<thead>
<tr>
<th class="col-xs-2">

View file

@ -1,22 +0,0 @@
- panel_class = @domain.errors.messages[:admin_contacts] ? 'panel-danger' : 'panel-default'
.panel{class: panel_class}
.panel-heading.clearfix
= t('.title')
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-4'}= t(:name)
%th{class: 'col-xs-4'}= t(:id)
%th{class: 'col-xs-4'}= t(:email)
%tbody
- @domain.admin_contacts.each do |ac|
%tr
%td= link_to(ac, registrant_contact_path(ac))
%td= ac.code
%td= ac.email
- if @domain.errors.messages[:admin_contacts]
%tfoot
- @domain.errors.messages[:admin_contacts].each do |x|
%tr
%td{colspan: 4}= x

View file

@ -0,0 +1,7 @@
<% contact = domain_contact.contact %>
<tr class="<%= domain_contact.model_name.singular.dasherize %>">
<td><%= link_to contact, registrant_domain_contact_path(domain, contact) %></td>
<td><%= contact.code %></td>
<td><%= contact.email %></td>
</tr>

View file

@ -0,0 +1,24 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t ".header_#{domain_contacts.model_name.plural.underscore}" %>
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed
<%= domain_contacts.model_name.plural.dasherize %>">
<thead>
<tr>
<th class="col-xs-4"><%= Contact.human_attribute_name :name %></th>
<th class="col-xs-4"><%= Contact.human_attribute_name :code %></th>
<th class="col-xs-4"><%= Contact.human_attribute_name :email %></th>
</tr>
</thead>
<tbody>
<%= render partial: 'registrant/domains/partials/domain_contact',
collection: domain_contacts,
locals: { domain: domain } %>
</tbody>
</table>
</div>
</div>

View file

@ -13,7 +13,7 @@
<dt><%= t(:registered_at) %></dt>
<dd><%= l(@domain.registered_at) %></dd>
<dt><%= t(:registrar_name) %></dt>
<dt><%= Registrar.model_name.human %></dt>
<dd><%= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) %></dd>
<dt><%= Domain.human_attribute_name :transfer_code %></dt>

View file

@ -1,19 +0,0 @@
.panel.panel-default
.panel-heading
%h3.panel-title= t('.title')
.panel-body
%dl.dl-horizontal
%dt= t(:name)
%dd= link_to(@domain.registrant.name, registrant_contact_path(@domain.registrant))
%dt= t(:id)
%dd= @domain.registrant_code
%dt= t(:identity_code)
%dd= @domain.registrant_ident
%dt= t(:email)
%dd= @domain.registrant_email
%dt= t(:phone)
%dd= @domain.registrant_phone

View file

@ -0,0 +1,26 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt><%= Registrant.human_attribute_name :name %></dt>
<dd>
<%= link_to registrant.name, registrant_domain_contact_path(domain, registrant) %>
</dd>
<dt><%= Registrant.human_attribute_name :code %></dt>
<dd><%= registrant.code %></dd>
<dt><%= Registrant.human_attribute_name :ident %></dt>
<dd><%= registrant.ident %></dd>
<dt><%= Registrant.human_attribute_name :email %></dt>
<dd><%= registrant.email %></dd>
<dt><%= Registrant.human_attribute_name :phone %></dt>
<dd><%= registrant.phone %></dd>
</dl>
</div>
</div>

View file

@ -1,22 +0,0 @@
- panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default'
#tech_contacts.panel{class: panel_class}
.panel-heading.clearfix
= t('.title')
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-4'}= t(:name)
%th{class: 'col-xs-4'}= t(:id)
%th{class: 'col-xs-4'}= t(:email)
%tbody
- @domain.tech_contacts.each do |tc|
%tr
%td= link_to(tc, registrant_contact_path(tc))
%td= tc.code
%td= tc.email
- if @domain.errors.messages[:tech_contacts]
%tfoot
- @domain.errors.messages[:tech_contacts].each do |x|
%tr
%td{colspan: 4}= x

View file

@ -1,23 +1,35 @@
<%= render 'shared/title', name: @domain.name %>
<ol class="breadcrumb">
<li><%= link_to t('registrant.domains.index.header'), registrant_domains_path %></li>
</ol>
<div class="page-header">
<h1><%= @domain %></h1>
</div>
<div class="row">
<div class="col-md-6">
<%= render 'registrant/domains/partials/general' %>
</div>
<div class="col-md-6">
<%= render 'registrant/domains/partials/owner' %>
<%= render partial: 'registrant/domains/partials/registrant',
locals: { registrant: @domain.registrant, domain: @domain } %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/tech_contacts' %>
<%= render 'registrant/domains/partials/domain_contacts',
domain: @domain,
domain_contacts: @domain.tech_domain_contacts %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<%= render 'registrant/domains/partials/admin_contacts' %>
<%= render 'registrant/domains/partials/domain_contacts',
domain: @domain,
domain_contacts: @domain.admin_domain_contacts %>
</div>
</div>