mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 12:08:27 +02:00
Merge branch 'master' into credit-and-debit-card-payments
This commit is contained in:
commit
d7afb3880a
16 changed files with 245 additions and 62 deletions
|
@ -1,5 +1,7 @@
|
|||
module Admin
|
||||
class ContactVersionsController < BaseController
|
||||
include ObjectVersionsHelper
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
module Admin
|
||||
class DomainVersionsController < BaseController
|
||||
include ObjectVersionsHelper
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
|
|
5
app/helpers/contact_helper.rb
Normal file
5
app/helpers/contact_helper.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
module ContactHelper
|
||||
def printable_street(street)
|
||||
street.to_s.gsub("\n", '<br>').html_safe
|
||||
end
|
||||
end
|
15
app/helpers/object_versions_helper.rb
Normal file
15
app/helpers/object_versions_helper.rb
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
8
app/views/for_models/whois_discarded.erb
Normal file
8
app/views/for_models/whois_discarded.erb
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue