Merge branch 'master' into registry-790

This commit is contained in:
Artur Beljajev 2018-06-04 04:02:33 +03:00
commit 65b40997ca
51 changed files with 556 additions and 303 deletions

View file

@ -3,13 +3,11 @@ module Admin
load_and_authorize_resource
def index
params[:q] ||= {}
domains = BlockedDomain.all.order(:name)
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
end
def new

View file

@ -1,5 +1,7 @@
module Admin
class ContactVersionsController < BaseController
include ObjectVersionsHelper
load_and_authorize_resource
def index
@ -24,7 +26,7 @@ module Admin
versions = ContactVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
@q = versions.search(params[:q])
@versions = @q.result.page(params[:page])
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
end

View file

@ -22,7 +22,7 @@ module Admin
@contacts = @q.result.uniq.page(params[:page])
end
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
end
def search

View file

@ -1,5 +1,7 @@
module Admin
class DomainVersionsController < BaseController
include ObjectVersionsHelper
load_and_authorize_resource
def index
@ -41,7 +43,7 @@ module Admin
versions = DomainVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc)
@q = versions.search(params[:q])
@versions = @q.result.page(params[:page])
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
@versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
render "admin/domain_versions/archive"
end

View file

@ -32,7 +32,7 @@ module Admin
end
end
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
end
# rubocop: enable Metrics/PerceivedComplexity

View file

@ -13,7 +13,7 @@ module Admin
@deposit = Deposit.new(deposit_params.merge(registrar: r))
@invoice = @deposit.issue_prepayment_invoice
if @invoice && @invoice.persisted?
if @invoice&.persisted?
flash[:notice] = t(:record_created)
redirect_to [:admin, @invoice]
else

View file

@ -4,13 +4,11 @@ module Admin
before_action :set_domain, only: [:edit, :update]
def index
params[:q] ||= {}
domains = ReservedDomain.all.order(:name)
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
end
def new

View file

@ -168,7 +168,7 @@ class EppController < ApplicationController
# validate legal document's type here because it may be in most of the requests
@prefix = nil
if element_count('extdata > legalDocument') > 0
if element_count('extdata > legalDocument').positive?
requires_attribute('extdata > legalDocument', 'type', values: LegalDocument::TYPES, policy: true)
end
@ -279,7 +279,7 @@ class EppController < ApplicationController
def optional(selector, *validations)
full_selector = [@prefix, selector].compact.join(' ')
el = params[:parsed_frame].css(full_selector).first
return unless el && el.text.present?
return unless el&.text.present?
value = el.text
validations.each do |x|

View file

@ -6,7 +6,7 @@ class Registrant::DomainsController < RegistrantController
@q = domains.search(params[:q])
@domains = @q.result.page(params[:page])
end
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
end
def show

View file

@ -1,3 +1,5 @@
# As non-GDPR compliant, this controller is deprecated. Needs to be replaced with one that relies
# on the REST WHOIS API.
class Registrant::WhoisController < RegistrantController
def index
authorize! :view, :registrant_whois

View file

@ -33,7 +33,7 @@ class Registrar
@contacts = @q.result(distinct: :true).page(params[:page])
end
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
@contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
end
def download_list

View file

@ -10,7 +10,7 @@ class Registrar
@deposit = Deposit.new(deposit_params.merge(registrar: current_user.registrar))
@invoice = @deposit.issue_prepayment_invoice
if @invoice && @invoice.persisted?
if @invoice&.persisted?
flash[:notice] = t(:please_pay_the_following_invoice)
redirect_to [:registrar, @invoice]
else

View file

@ -40,7 +40,7 @@ class Registrar
end
end
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0
@domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i.positive?
respond_to do |format|
format.html

View file

@ -0,0 +1,15 @@
module ObjectVersionsHelper
def attach_existing_fields(version, new_object)
version.object_changes.to_h.each do |key, value|
method_name = "#{key}=".to_sym
if new_object.respond_to?(method_name)
new_object.public_send(method_name, value.last)
end
end
end
def only_present_fields(version, model)
field_names = model.column_names
version.object.to_h.select { |key, _value| field_names.include?(key) }
end
end

View file

@ -51,4 +51,4 @@ class UpdateWhoisRecordJob < Que::Job
def delete_blocked(name)
delete_reserved(name)
end
end
end

View file

@ -13,9 +13,9 @@ class Ability
case @user.class.to_s
when 'AdminUser'
@user.roles.each { |role| send(role) } if @user.roles
@user.roles&.each { |role| send(role) }
when 'ApiUser'
@user.roles.each { |role| send(role) } if @user.roles
@user.roles&.each { |role| send(role) }
when 'RegistrantUser'
static_registrant
end

View file

@ -45,8 +45,10 @@ class Directo < ActiveRecord::Base
end
data = builder.to_xml.gsub("\n",'')
response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s
dump_result_to_db(mappers, response)
Rails.logger.info("[Directo] XML request: #{data}")
response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false)
Rails.logger.info("[Directo] Directo responded with code: #{response.code}, body: #{response.body}")
dump_result_to_db(mappers, response.to_s)
end
STDOUT << "#{Time.zone.now.utc} - Directo receipts sending finished. #{counter} of #{total} are sent\n"
@ -165,11 +167,15 @@ class Directo < ActiveRecord::Base
end
data = builder.to_xml.gsub("\n",'')
Rails.logger.info("[Directo] XML request: #{data}")
if debug
STDOUT << "#{Time.zone.now.utc} - Directo xml had to be sent #{data}\n"
else
response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s
response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false)
Rails.logger.info("[Directo] Directo responded with code: #{response.code}, body: #{response.body}")
response = response.to_s
Setting.directo_monthly_number_last = directo_next
Nokogiri::XML(response).css("Result").each do |res|
Directo.create!(request: data, response: res.as_json.to_h, invoice_number: directo_next)
@ -190,4 +196,3 @@ class Directo < ActiveRecord::Base
@pricelists[account_activity.price_id] = account_activity.price
end
end

View file

@ -147,7 +147,7 @@ class Epp::Contact < Contact
end
if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame))
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
frame.css("legalDocument").first.content = doc.path if doc&.persisted?
self.legal_document_id = doc.id
end
@ -238,7 +238,7 @@ class Epp::Contact < Contact
)
self.legal_documents = [doc]
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
frame.css("legalDocument").first.content = doc.path if doc&.persisted?
self.legal_document_id = doc.id
end

View file

@ -197,7 +197,7 @@ class Epp::Domain < Domain
)
self.legal_documents = [doc]
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
frame.css("legalDocument").first.content = doc.path if doc&.persisted?
self.legal_document_id = doc.id
end
# rubocop: enable Metrics/PerceivedComplexity
@ -472,7 +472,7 @@ class Epp::Domain < Domain
at.deep_merge!(attrs_from(frame.css('rem'), current_user, 'rem'))
if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame))
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
frame.css("legalDocument").first.content = doc.path if doc&.persisted?
self.legal_document_id = doc.id
end
@ -547,7 +547,7 @@ class Epp::Domain < Domain
check_discarded
if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame))
frame.css("legalDocument").first.content = doc.path if doc && doc.persisted?
frame.css("legalDocument").first.content = doc.path if doc&.persisted?
end
if Setting.request_confirmation_on_domain_deletion_enabled &&

View file

@ -6,7 +6,8 @@ class LegalDocument < ActiveRecord::Base
if ENV['legal_document_types'].present?
TYPES = ENV['legal_document_types'].split(',').map(&:strip)
else
TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z odt doc docx).freeze
TYPES = %w(pdf asice asics sce scs adoc edoc bdoc ddoc zip rar gz tar 7z odt
doc docx).freeze
end
attr_accessor :body

View file

@ -36,6 +36,7 @@ class WhoisRecord < ActiveRecord::Base
registrant = domain.registrant
@disclosed = []
h[:disclaimer] = disclaimer_text if disclaimer_text.present?
h[:name] = domain.name
h[:status] = domain.statuses.map { |x| status_map[x] || x }
h[:registered] = domain.registered_at.try(:to_s, :iso8601)
@ -120,4 +121,10 @@ class WhoisRecord < ActiveRecord::Base
def destroy_whois_record
Whois::Record.where(name: name).delete_all
end
private
def disclaimer_text
Setting.registry_whois_disclaimer
end
end

View file

@ -37,7 +37,7 @@ class DomainNameValidator < ActiveModel::EachValidator
def validate_blocked(value)
return true unless value
return false if BlockedDomain.where(name: value).count > 0
return false if BlockedDomain.where(name: value).count.positive?
DNS::Zone.where(origin: value).count.zero?
end
end

View file

@ -57,8 +57,9 @@
%tbody
- @versions.each do |version|
- if version
- contact = Contact.new(version.object.to_h)
- version.object_changes.to_h.each { |k,v| contact.public_send("#{k}=", v.last) }
- attributes = only_present_fields(version, Contact)
- contact = Contact.new(attributes)
- attach_existing_fields(version, contact)
%tr
%td= link_to(contact.name, admin_contact_version_path(version.id))

View file

@ -1,5 +1,6 @@
- contact = Contact.new(@version.object.to_h)
- @version.object_changes.to_h.each { |k,v| contact.public_send("#{k}=", v.last ) }
- attributes = only_present_fields(@version, Contact)
- contact = Contact.new(attributes)
- attach_existing_fields(@version, contact)
= render 'shared/title', name: contact.name
.row
@ -41,11 +42,11 @@
%br
%dt= t(:created)
%dt= t(:created_at)
%dd{class: changing_css_class(@version,"created_at")}
= l(contact.created_at, format: :short)
%dt= t(:updated)
%dt= t(:updated_at)
%dd{class: changing_css_class(@version,"updated_at")}
= l(contact.updated_at, format: :short)
@ -61,7 +62,7 @@
- if contact.street.present?
%dt= t(:street)
%dd{class: changing_css_class(@version,"street")}= contact.street.to_s.gsub("\n", '<br>').html_safe
%dd{class: changing_css_class(@version,"street")}= contact.street
- if contact.city.present?
%dt= t(:city)

View file

@ -55,8 +55,9 @@
%tbody
- @versions.each do |version|
- if version
- domain = Domain.new(version.object.to_h)
- version.object_changes.to_h.each{|k,v| domain.public_send("#{k}=", v.last) }
- attributes = only_present_fields(version, Domain)
- domain = Domain.new(attributes)
- attach_existing_fields(version, domain)
%tr
%td= link_to(domain.name, admin_domain_version_path(version.id))

View file

@ -1,5 +1,6 @@
- domain = Domain.new(@version.object.to_h)
- @version.object_changes.to_h.each{|k,v| domain.public_send("#{k}=", v.last) }
- present_fields = only_present_fields(@version, Domain)
- domain = Domain.new(present_fields)
- attach_existing_fields(@version, domain)
- if @version
- children = HashWithIndifferentAccess.new(@version.children)

View file

@ -99,6 +99,7 @@
= render 'setting_row', var: :registry_state
= render 'setting_row', var: :registry_zip
= render 'setting_row', var: :registry_country_code
= render 'setting_row', var: :registry_whois_disclaimer
.row
.col-md-12.text-right

View file

@ -22,7 +22,7 @@ xml.epp_head do
xml.tag!('domain:contact', ac.code, 'type' => 'admin')
end
if @nameservers && @nameservers.any?
if @nameservers&.any?
xml.tag!('domain:ns') do
@nameservers.each do |x|
xml.tag!('domain:hostAttr') do

View file

@ -1,3 +1,6 @@
<%- if json['disclaimer'].present? -%>
<%= json['disclaimer'].scan(/\S.{0,72}\S(?=\s|$)|\S+/).join("\n") %>
<%- end -%>
Estonia .ee Top Level Domain WHOIS server
Domain:
@ -23,18 +26,18 @@ changed: <%= json['registrant_changed'].to_s.tr('T',' ').sub('+', ' +') %>
<%- if json['admin_contacts'].present? -%>
Administrative contact:
<%- for contact in json['admin_contacts'] -%>
name: <%= contact['name'] %>
name: Not Disclosed
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
changed: <%= contact['changed'].to_s.tr('T',' ').sub('+', ' +') %>
changed: Not Disclosed
<%- end -%>
<%- end -%>
<% if json['tech_contacts'].present? %>
Technical contact:
<%- for contact in json['tech_contacts'] -%>
name: <%= contact['name'] %>
name: Not Disclosed
email: Not Disclosed - Visit www.internet.ee for webbased WHOIS
changed: <%= contact['changed'].to_s.tr('T',' ').sub('+', ' +') %>
changed: Not Disclosed
<%- end -%>
<%- end -%>

View file

@ -1,54 +0,0 @@
!!! 5
%html{lang: I18n.locale.to_s}
%head
%meta{charset: "utf-8"}/
%meta{content: "width=device-width, initial-scale=1", name: "viewport"}/
- if content_for? :head_title
= yield :head_title
- else
%title= t(:registrant_head_title)
= csrf_meta_tags
= stylesheet_link_tag 'registrant-manifest', media: 'all'
= favicon_link_tag 'favicon.ico'
%body
/ Fixed navbar
%nav.navbar.navbar-default.navbar-fixed-top
.container
.navbar-header
%button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"}
%span.sr-only Toggle navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
= link_to registrant_root_path, class: 'navbar-brand' do
= t(:registrant_head_title)
- if unstable_env.present?
.text-center
%small{style: 'color: #0074B3;'}= unstable_env
- if current_user
.navbar-collapse.collapse
%ul.nav.navbar-nav.public-nav
- if can? :view, Depp::Domain
- active_class = %w(registrant/domains registrant/check registrant/renew registrant/tranfer registrant/keyrelays).include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:domains), registrant_domains_path
- active_class = %w(registrant/whois).include?(params[:controller]) ? 'active' :nil
%li{class: active_class}= link_to t(:whois), registrant_whois_path
%ul.nav.navbar-nav.navbar-right
- if user_signed_in?
%li= link_to t(:log_out, user: current_user), '/registrant/logout'
.container
= render 'shared/flash'
= yield
%footer.footer
.container
.row
.col-md-6
= image_tag 'eis-logo-et.png'
.col-md-6.text-right
Version
= CURRENT_COMMIT_HASH
= javascript_include_tag 'registrant-manifest', async: true

View file

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="<%= I18n.locale.to_s %>">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<% if content_for? :head_title %>
<%= yield :head_title %>
<% else %>
<title>
<%= t(:registrant_head_title) %>
</title>
<% end %>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'registrant-manifest', media: 'all' %>
<%= favicon_link_tag 'favicon.ico' %>
</head>
<body>
<!-- Fixed navbar
-->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button aria-controls="navbar" aria-expanded="false" class="navbar-toggle collapsed" data-target="#navbar" data-toggle="collapse" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<%= link_to registrant_root_path, class: 'navbar-brand' do %>
<%= t(:registrant_head_title) %>
<% if unstable_env.present? %>
<div class="text-center">
<small style="color: #0074B3;">
<%= unstable_env %>
</small>
</div>
<% end %>
<% end %>
</div>
<% if current_user %>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav public-nav">
<% if can? :view, Depp::Domain %>
<% active_class = %w(registrant/domains registrant/check registrant/renew registrant/tranfer registrant/keyrelays).include?(params[:controller]) ? 'active' :nil %>
<li class="<%= active_class %>">
<%= link_to t(:domains), registrant_domains_path %>
</li>
<% end %>
<% active_class = %w(registrant/whois).include?(params[:controller]) ? 'active' :nil %>
<li class="<%= active_class %>">
<%= link_to 'Internet.ee', 'https://internet.ee' %>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<% if user_signed_in? %>
<li>
<%= link_to t(:log_out, user: current_user), '/registrant/logout' %>
</li>
<% end %>
</ul>
</div>
<% end %>
</div>
</nav>
<div class="container">
<%= render 'shared/flash' %>
<%= yield %>
</div>
<footer class="footer">
<div class="container">
<div class="row">
<div class="col-md-6">
<%= image_tag 'eis-logo-et.png' %>
</div>
<div class="col-md-6 text-right">
Version
<%= CURRENT_COMMIT_HASH %>
</div>
</div>
</div>
</footer>
<%= javascript_include_tag 'registrant-manifest', async: true %>
</body>
</html>

View file

@ -8,7 +8,7 @@
%dd= @contact.org_name
%dt= t(:street)
%dd= @contact.street.to_s.gsub("\n", '<br>').html_safe
%dd= @contact.street
%dt= t(:city)
%dd= @contact.city