mirror of
https://github.com/internetee/registry.git
synced 2025-07-04 02:03:36 +02:00
Domain versioning
This commit is contained in:
parent
d94eb22fc6
commit
a41505e319
16 changed files with 212 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
||||||
class Admin::ContactVersionsController < AdminController
|
class Admin::ContactVersionsController < AdminController
|
||||||
before_action :set_contact
|
before_action :set_contact, only: [:show]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@q = Contact.search(params[:q])
|
@q = Contact.search(params[:q])
|
||||||
|
|
17
app/controllers/admin/domain_versions_controller.rb
Normal file
17
app/controllers/admin/domain_versions_controller.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
class Admin::DomainVersionsController < AdminController
|
||||||
|
before_action :set_domain, only: [:show]
|
||||||
|
|
||||||
|
def index
|
||||||
|
@q = Domain.search(params[:q])
|
||||||
|
@domains = @q.result.page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@versions = @domain.versions
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def set_domain
|
||||||
|
@domain = Domain.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
|
@ -56,6 +56,9 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
attr_accessor :owner_contact_typeahead
|
attr_accessor :owner_contact_typeahead
|
||||||
|
|
||||||
|
# archiving
|
||||||
|
has_paper_trail class_name: 'DomainVersion'
|
||||||
|
|
||||||
def name=(value)
|
def name=(value)
|
||||||
value.strip!
|
value.strip!
|
||||||
write_attribute(:name, SimpleIDN.to_unicode(value))
|
write_attribute(:name, SimpleIDN.to_unicode(value))
|
||||||
|
|
|
@ -33,6 +33,9 @@ class DomainStatus < ActiveRecord::Base
|
||||||
CLIENT_STATUSES = [CLIENT_DELETE_PROHIBITED, CLIENT_HOLD, CLIENT_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED]
|
CLIENT_STATUSES = [CLIENT_DELETE_PROHIBITED, CLIENT_HOLD, CLIENT_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED]
|
||||||
SERVER_STATUSES = [SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED, SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED]
|
SERVER_STATUSES = [SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED, SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED]
|
||||||
|
|
||||||
|
# archiving
|
||||||
|
has_paper_trail class_name: 'DomainStatusVersion'
|
||||||
|
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
{
|
{
|
||||||
'2302' => [ # Object exists
|
'2302' => [ # Object exists
|
||||||
|
|
4
app/models/domain_status_version.rb
Normal file
4
app/models/domain_status_version.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
class DomainStatusVersion < PaperTrail::Version
|
||||||
|
self.table_name = :domain_status_versions
|
||||||
|
self.sequence_name = :domain_status_version_id_seq
|
||||||
|
end
|
4
app/models/domain_version.rb
Normal file
4
app/models/domain_version.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
class DomainVersion < PaperTrail::Version
|
||||||
|
self.table_name = :domain_versions
|
||||||
|
self.sequence_name = :domain_version_id_seq
|
||||||
|
end
|
|
@ -8,6 +8,9 @@ class Nameserver < ActiveRecord::Base
|
||||||
validates :ipv4, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_blank: true }
|
validates :ipv4, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_blank: true }
|
||||||
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true }
|
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true }
|
||||||
|
|
||||||
|
# archiving
|
||||||
|
has_paper_trail class_name: 'NameserverVersion'
|
||||||
|
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
{
|
{
|
||||||
'2302' => [
|
'2302' => [
|
||||||
|
|
4
app/models/nameserver_version.rb
Normal file
4
app/models/nameserver_version.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
class NameserverVersion < PaperTrail::Version
|
||||||
|
self.table_name = :nameserver_versions
|
||||||
|
self.sequence_name = :nameserver_version_id_seq
|
||||||
|
end
|
23
app/views/admin/contact_versions/_history.haml
Normal file
23
app/views/admin/contact_versions/_history.haml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt= t('shared.name')
|
||||||
|
%dd= contact.name
|
||||||
|
%dt= t('shared.ident')
|
||||||
|
%dd= contact.ident
|
||||||
|
%dt= t('shared.phone')
|
||||||
|
%dd= contact.phone
|
||||||
|
%dt= t('shared.email')
|
||||||
|
%dd= contact.email
|
||||||
|
%dt= t('shared.fax')
|
||||||
|
%dd= contact.fax
|
||||||
|
%dt= t('shared.org_name')
|
||||||
|
%dd= contact.org_name
|
||||||
|
.col-md-6
|
||||||
|
%dl.dl-horizontal
|
||||||
|
- if contact.address
|
||||||
|
%dt= t('shared.city')
|
||||||
|
%dd= contact.address.city
|
||||||
|
%dt= t('shared.street')
|
||||||
|
%dd= contact.address.street
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
%th
|
%th
|
||||||
created_at
|
created_at
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%tbody
|
%tbody
|
||||||
- @versions.each_with_index do |version, index|
|
- @versions.each_with_index do |version, index|
|
||||||
- contact = version.reify(has_one: true)
|
- contact = version.reify(has_one: true)
|
||||||
|
@ -32,31 +29,9 @@
|
||||||
%td=version.created_at #contact.email if contact
|
%td=version.created_at #contact.email if contact
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td{colspan: "3"}
|
%td
|
||||||
.collapse{ id: "accordion-#{index}" }
|
.collapse{ id: "accordion-#{index}" }
|
||||||
.row
|
= render 'admin/contact_versions/history', contact: contact
|
||||||
.col-md-6
|
|
||||||
%dl.dl-horizontal
|
|
||||||
%dt= t('shared.name')
|
|
||||||
%dd= contact.name
|
|
||||||
%dt= t('shared.ident')
|
|
||||||
%dd= contact.ident
|
|
||||||
%dt= t('shared.phone')
|
|
||||||
%dd= contact.phone
|
|
||||||
%dt= t('shared.email')
|
|
||||||
%dd= contact.email
|
|
||||||
%dt= t('shared.fax')
|
|
||||||
%dd= contact.fax
|
|
||||||
%dt= t('shared.org_name')
|
|
||||||
%dd= contact.org_name
|
|
||||||
.col-md-6
|
|
||||||
%dl.dl-horizontal
|
|
||||||
- if contact.address
|
|
||||||
%dt= t('shared.city')
|
|
||||||
%dd= contact.address.city
|
|
||||||
%dt= t('shared.street')
|
|
||||||
%dd= contact.address.street
|
|
||||||
|
|
||||||
- else
|
- else
|
||||||
%tr
|
%tr
|
||||||
%td=version.whodunnit #contact.name if contact
|
%td=version.whodunnit #contact.name if contact
|
||||||
|
|
56
app/views/admin/domain_versions/_history.haml
Normal file
56
app/views/admin/domain_versions/_history.haml
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
%tr.clickable{"data-target" => "#accordion-#{index}", "data-toggle" => "collapse"}
|
||||||
|
%td=version.whodunnit #contact.name if contact
|
||||||
|
%td=version.event #contact.ident if contact
|
||||||
|
%td=version.created_at #contact.email if contact
|
||||||
|
|
||||||
|
%tr
|
||||||
|
%td{colspan: "3"}
|
||||||
|
.collapse{ id: "accordion-#{index}" }
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt= t('shared.name')
|
||||||
|
%dd= domain.name
|
||||||
|
%dt= t('shared.status')
|
||||||
|
%dd= domain.status
|
||||||
|
%dt= t('shared.valid_from')
|
||||||
|
%dd= domain.valid_from
|
||||||
|
%dt= t('shared.valid_to')
|
||||||
|
%dd= domain.valid_to
|
||||||
|
%dt= t('shared.period')
|
||||||
|
%dd= domain.period
|
||||||
|
%dt= t('shared.period_unit')
|
||||||
|
%dd= domain.period_unit
|
||||||
|
%dt= t('shared.status')
|
||||||
|
%dd= domain.status
|
||||||
|
.col-md-6
|
||||||
|
%dl.dl-horizontal
|
||||||
|
- if domain.nameservers
|
||||||
|
- domain.nameservers.each do |ns|
|
||||||
|
%dt= t('shared.hostname')
|
||||||
|
%dd= ns.hostname
|
||||||
|
%dt= t('shared.ipv4')
|
||||||
|
%dd= ns.ipv4
|
||||||
|
- if domain.domain_statuses
|
||||||
|
- domain.domain_statuses.each do |ds|
|
||||||
|
%dt= t('shared.value')
|
||||||
|
%dd= ds.value
|
||||||
|
%dt= t('shared.description')
|
||||||
|
%dd= ds.description
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
- if domain.owner_contact
|
||||||
|
%h2= t('shared.contacts')
|
||||||
|
= render 'admin/contact_versions/history', contact: domain.owner_contact
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
- if domain.domain_contacts
|
||||||
|
.row
|
||||||
|
- if domain.tech_contacts
|
||||||
|
- domain.tech_contacts.each do |contact|
|
||||||
|
= render 'admin/contact_versions/history', contact: contact
|
||||||
|
- if domain.admin_contacts
|
||||||
|
- domain.admin_contacts.each do |contact|
|
||||||
|
= render 'admin/contact_versions/history', contact: contact
|
39
app/views/admin/domain_versions/index.haml
Normal file
39
app/views/admin/domain_versions/index.haml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
.row
|
||||||
|
.col-sm-12
|
||||||
|
%h2.text-center-xs= t('shared.domains')
|
||||||
|
%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')
|
||||||
|
%th{class: 'col-xs-2'}
|
||||||
|
= sort_link(@q, 'registrar_name', t('shared.registrar'))
|
||||||
|
%th{class: 'col-xs-2'}
|
||||||
|
= sort_link(@q, 'owner_contact_name', t('shared.owner'))
|
||||||
|
%th{class: 'col-xs-1'}
|
||||||
|
whodunnit
|
||||||
|
%th{class: 'col-xs1'}
|
||||||
|
event
|
||||||
|
%th{class: 'col-xs1'}
|
||||||
|
created_at
|
||||||
|
%th{class: 'col-xs1'}
|
||||||
|
= t('shared.action')
|
||||||
|
|
||||||
|
%tbody
|
||||||
|
- @domains.each do |domain|
|
||||||
|
%tr
|
||||||
|
%td= domain.name
|
||||||
|
%td= domain.registrar.name if domain.registrar
|
||||||
|
%td= domain.owner_contact.name if domain.owner_contact
|
||||||
|
%td= domain.versions.last.whodunnit if domain.versions.last
|
||||||
|
%td= domain.versions.last.event if domain.versions.last
|
||||||
|
%td= domain.versions.last.created_at if domain.versions.last
|
||||||
|
%td= link_to(t('shared.history'), admin_domain_version_path(domain), class: 'btn btn-primary btn-xs')
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
= paginate @domains
|
32
app/views/admin/domain_versions/show.haml
Normal file
32
app/views/admin/domain_versions/show.haml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-center-xs
|
||||||
|
= "#{t('shared.contact_details')}"
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-right.text-center-xs
|
||||||
|
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.table-responsive
|
||||||
|
%table.table.table-hover.table-bordered.table-condensed
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th
|
||||||
|
whodunnit
|
||||||
|
%th
|
||||||
|
event
|
||||||
|
%th
|
||||||
|
created_at
|
||||||
|
|
||||||
|
%tbody
|
||||||
|
- @versions.each_with_index do |version, index|
|
||||||
|
- domain = version.reify(has_multiple: true)
|
||||||
|
- if domain
|
||||||
|
= render 'admin/domain_versions/history', version: version, index: index, domain: domain
|
||||||
|
- else
|
||||||
|
%tr
|
||||||
|
%td=version.whodunnit #contact.name if contact
|
||||||
|
%td=version.event #contact.ident if contact
|
||||||
|
%td=version.created_at #contact.email if contact
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
%ul.dropdown-menu{role: "menu"}
|
%ul.dropdown-menu{role: "menu"}
|
||||||
%li.dropdown-header= t('shared.domain')
|
%li.dropdown-header= t('shared.domain')
|
||||||
%li
|
%li
|
||||||
= link_to t('shared.domains'), '#'
|
= link_to t('shared.domains'), admin_domain_versions_path
|
||||||
%li.dropdown-header= t('shared.contact')
|
%li.dropdown-header= t('shared.contact')
|
||||||
%li
|
%li
|
||||||
= link_to t('shared.contacts'), admin_contact_versions_path
|
= link_to t('shared.contacts'), admin_contact_versions_path
|
||||||
|
|
|
@ -24,7 +24,8 @@ Rails.application.routes.draw do
|
||||||
resources :users
|
resources :users
|
||||||
resources :epp_users
|
resources :epp_users
|
||||||
resources :contact_versions
|
resources :contact_versions
|
||||||
resources :address_versions
|
#resources :address_versions
|
||||||
|
resources :domain_versions
|
||||||
|
|
||||||
root 'domains#index'
|
root 'domains#index'
|
||||||
|
|
||||||
|
|
18
db/migrate/20140926121409_domain_related_archives.rb
Normal file
18
db/migrate/20140926121409_domain_related_archives.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
class DomainRelatedArchives < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
tables = [:domain_versions, :nameserver_versions, :domain_status_versions ]
|
||||||
|
tables.each do |table|
|
||||||
|
create_table table do |t|
|
||||||
|
t.string :item_type, :null => false
|
||||||
|
t.integer :item_id, :null => false
|
||||||
|
t.string :event, :null => false
|
||||||
|
t.string :whodunnit
|
||||||
|
t.text :object
|
||||||
|
t.datetime :created_at
|
||||||
|
end
|
||||||
|
add_index table, [:item_type, :item_id]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue