Merge branch 'master' into credit-and-debit-card-payments

This commit is contained in:
Maciej Szlosarczyk 2018-04-30 11:38:19 +03:00
commit d7afb3880a
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
16 changed files with 245 additions and 62 deletions

View file

@ -1,5 +1,7 @@
module Admin
class ContactVersionsController < BaseController
include ObjectVersionsHelper
load_and_authorize_resource
def index

View file

@ -1,5 +1,7 @@
module Admin
class DomainVersionsController < BaseController
include ObjectVersionsHelper
load_and_authorize_resource
def index

View file

@ -0,0 +1,5 @@
module ContactHelper
def printable_street(street)
street.to_s.gsub("\n", '<br>').html_safe
end
end

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

@ -23,6 +23,12 @@ class WhoisRecord < ActiveRecord::Base
h = HashWithIndifferentAccess.new
return h if domain.blank?
if domain.discarded?
h[:name] = domain.name
h[:status] = ['deleteCandidate']
return h
end
status_map = {
'ok' => 'ok (paid and in zone)'
}
@ -88,7 +94,8 @@ class WhoisRecord < ActiveRecord::Base
end
def generated_body
template = Rails.root.join("app/views/for_models/whois.erb".freeze)
template_name = domain.discarded? ? 'whois_discarded.erb' : 'whois.erb'
template = Rails.root.join("app/views/for_models/#{template_name}".freeze)
ERB.new(template.read, nil, "-").result(binding)
end
# rubocop:enable Metrics/MethodLength

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")}= printable_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

@ -0,0 +1,8 @@
Estonia .ee Top Level Domain WHOIS server
Domain:
name: <%= json['name'] %>
status: <%= json['status'] %>
Estonia .ee Top Level Domain WHOIS server
More information at http://internet.ee

View file

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