mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
Logging contacts and addresses,view undeleted ones
This commit is contained in:
parent
bb3d2cc88a
commit
d94eb22fc6
14 changed files with 263 additions and 3 deletions
3
Gemfile
3
Gemfile
|
@ -58,6 +58,9 @@ gem 'cancan', '~> 1.6.10'
|
|||
# for login
|
||||
gem 'devise', '~> 3.3.0'
|
||||
|
||||
# for archiving
|
||||
gem 'paper_trail', '~> 3.0.5'
|
||||
|
||||
group :assets do
|
||||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||
gem 'therubyracer', platforms: :ruby
|
||||
|
|
|
@ -125,6 +125,9 @@ GEM
|
|||
mini_portile (= 0.6.0)
|
||||
nprogress-rails (0.1.3.1)
|
||||
orm_adapter (0.5.0)
|
||||
paper_trail (3.0.5)
|
||||
activerecord (>= 3.0, < 5.0)
|
||||
activesupport (>= 3.0, < 5.0)
|
||||
parser (2.2.0.pre.4)
|
||||
ast (>= 1.1, < 3.0)
|
||||
slop (~> 3.4, >= 3.4.5)
|
||||
|
@ -282,6 +285,7 @@ DEPENDENCIES
|
|||
kaminari (~> 0.16.1)
|
||||
nokogiri (~> 1.6.2.1)
|
||||
nprogress-rails (~> 0.1.3.1)
|
||||
paper_trail (~> 3.0.5)
|
||||
pg
|
||||
phantomjs (~> 1.9.7.1)
|
||||
phantomjs-binaries (~> 1.9.2.4)
|
||||
|
|
17
app/controllers/admin/contact_versions_controller.rb
Normal file
17
app/controllers/admin/contact_versions_controller.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class Admin::ContactVersionsController < AdminController
|
||||
before_action :set_contact
|
||||
|
||||
def index
|
||||
@q = Contact.search(params[:q])
|
||||
@contacts = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
@versions = @contact.versions
|
||||
end
|
||||
|
||||
private
|
||||
def set_contact
|
||||
@contact = Contact.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -10,8 +10,7 @@ class Address < ActiveRecord::Base
|
|||
belongs_to :contact
|
||||
belongs_to :country
|
||||
|
||||
# TODO: validate inclusion of :type in LONG_TYPES or smth similar
|
||||
# validates_inclusion_of :type, in: TYPES
|
||||
has_paper_trail class_name: 'AddressVersion'
|
||||
|
||||
class << self
|
||||
# def validate_postal_info_types(parsed_frame)
|
||||
|
|
4
app/models/address_version.rb
Normal file
4
app/models/address_version.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class AddressVersion < PaperTrail::Version
|
||||
self.table_name = :address_versions
|
||||
self.sequence_name = :address_version_id_seq
|
||||
end
|
|
@ -1,6 +1,7 @@
|
|||
class Contact < ActiveRecord::Base
|
||||
# TODO: Foreign contact will get email with activation link/username/temp password
|
||||
# TODO: Phone number validation, in first phase very minimam in order to support current registries
|
||||
# TODO: Validate presence of name
|
||||
|
||||
include EppErrors
|
||||
|
||||
|
@ -32,6 +33,9 @@ class Contact < ActiveRecord::Base
|
|||
delegate :street, to: :address#, prefix: true
|
||||
delegate :zip, to: :address#, prefix: true
|
||||
|
||||
# archiving
|
||||
has_paper_trail class_name: 'AddressVersion'
|
||||
|
||||
IDENT_TYPE_ICO = 'ico'
|
||||
IDENT_TYPES = [
|
||||
IDENT_TYPE_ICO, # Company registry code (or similar)
|
||||
|
|
4
app/models/contact_version.rb
Normal file
4
app/models/contact_version.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class ContactVersion < PaperTrail::Version
|
||||
self.table_name = :contact_versions
|
||||
self.sequence_name = :contact_version_id_seq
|
||||
end
|
40
app/views/admin/contact_versions/index.haml
Normal file
40
app/views/admin/contact_versions/index.haml
Normal file
|
@ -0,0 +1,40 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs= t('shared.contacts_history')
|
||||
= render 'admin/contacts/partials/search'
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
= link_to(t('shared.add'), new_admin_contact_path, class: 'btn btn-primary')
|
||||
%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', t('shared.name'))
|
||||
%th{class: 'col-xs-1'}
|
||||
= sort_link(@q, 'code', t('shared.code'))
|
||||
%th{class: 'col-xs-1'}
|
||||
whodunnit
|
||||
= #sort_link(@q, 'ident', t('shared.identity_code'))
|
||||
%th{class: 'col-xs-1'}
|
||||
event
|
||||
= #sort_link(@q, 'email', t('shared.email'))
|
||||
%th{class: 'col-xs-2'}
|
||||
created_at
|
||||
%th{class: 'col-xs-1'}
|
||||
= t('shared.action')
|
||||
%tbody
|
||||
- @contacts.each do |x|
|
||||
%tr
|
||||
%td= x.name #link_to(x, admin_contact_path(x))
|
||||
%td= x.code #link_to(x, admin_contact_path(x))
|
||||
%td= x.versions.last.whodunnit if x.versions.last
|
||||
%td= x.versions.last.event if x.versions.last
|
||||
%td= x.versions.last.created_at if x.versions.last
|
||||
%td= link_to(t('shared.history'), admin_contact_version_path(x), class: 'btn btn-primary btn-xs')
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @contacts
|
65
app/views/admin/contact_versions/show.haml
Normal file
65
app/views/admin/contact_versions/show.haml
Normal file
|
@ -0,0 +1,65 @@
|
|||
.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|
|
||||
- contact = version.reify(has_one: true)
|
||||
- if contact
|
||||
%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= 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
|
||||
%tr
|
||||
%td=version.whodunnit #contact.name if contact
|
||||
%td=version.event #contact.ident if contact
|
||||
%td=version.created_at #contact.email if contact
|
||||
|
|
@ -43,6 +43,19 @@
|
|||
= link_to t('shared.epp_users'), admin_epp_users_path
|
||||
%li
|
||||
= link_to t('shared.users'), admin_users_path
|
||||
|
||||
%li.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
|
||||
= t('shared.archives')
|
||||
%span.caret
|
||||
%ul.dropdown-menu{role: "menu"}
|
||||
%li.dropdown-header= t('shared.domain')
|
||||
%li
|
||||
= link_to t('shared.domains'), '#'
|
||||
%li.dropdown-header= t('shared.contact')
|
||||
%li
|
||||
= link_to t('shared.contacts'), admin_contact_versions_path
|
||||
|
||||
%ul.nav.navbar-nav.navbar-right
|
||||
%li= link_to t('shared.log_out', user: current_user), '/logout'
|
||||
/ /.nav-collapse
|
||||
|
|
|
@ -23,9 +23,12 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :users
|
||||
resources :epp_users
|
||||
resources :contact_versions
|
||||
resources :address_versions
|
||||
|
||||
root 'domains#index'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
## CLIENT ROUTES
|
||||
namespace(:client) do
|
||||
|
|
13
db/migrate/20140926081324_create_versions.rb
Normal file
13
db/migrate/20140926081324_create_versions.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class CreateVersions < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :versions 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 :versions, [:item_type, :item_id]
|
||||
end
|
||||
end
|
25
db/migrate/20140926082627_contact_and_version_archiving.rb
Normal file
25
db/migrate/20140926082627_contact_and_version_archiving.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
class ContactAndVersionArchiving < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :contact_versions 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
|
||||
|
||||
create_table :address_versions 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 :contact_versions, [:item_type, :item_id]
|
||||
add_index :address_versions, [:item_type, :item_id]
|
||||
|
||||
end
|
||||
end
|
66
db/schema.rb
66
db/schema.rb
|
@ -16,6 +16,17 @@ ActiveRecord::Schema.define(version: 20141001085322) do
|
|||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table "address_versions", force: true 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 "address_versions", ["item_type", "item_id"], name: "index_address_versions_on_item_type_and_item_id", using: :btree
|
||||
|
||||
create_table "addresses", force: true do |t|
|
||||
t.integer "contact_id"
|
||||
t.integer "country_id"
|
||||
|
@ -43,6 +54,17 @@ ActiveRecord::Schema.define(version: 20141001085322) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "contact_versions", force: true 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 "contact_versions", ["item_type", "item_id"], name: "index_contact_versions_on_item_type_and_item_id", using: :btree
|
||||
|
||||
create_table "contacts", force: true do |t|
|
||||
t.string "code"
|
||||
t.string "type"
|
||||
|
@ -84,6 +106,17 @@ ActiveRecord::Schema.define(version: 20141001085322) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "domain_status_versions", force: true 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 "domain_status_versions", ["item_type", "item_id"], name: "index_domain_status_versions_on_item_type_and_item_id", using: :btree
|
||||
|
||||
create_table "domain_statuses", force: true do |t|
|
||||
t.integer "domain_id"
|
||||
t.string "description"
|
||||
|
@ -102,6 +135,17 @@ ActiveRecord::Schema.define(version: 20141001085322) do
|
|||
t.datetime "wait_until"
|
||||
end
|
||||
|
||||
create_table "domain_versions", force: true 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 "domain_versions", ["item_type", "item_id"], name: "index_domain_versions_on_item_type_and_item_id", using: :btree
|
||||
|
||||
create_table "domains", force: true do |t|
|
||||
t.string "name"
|
||||
t.integer "registrar_id"
|
||||
|
@ -140,6 +184,17 @@ ActiveRecord::Schema.define(version: 20141001085322) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "nameserver_versions", force: true 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 "nameserver_versions", ["item_type", "item_id"], name: "index_nameserver_versions_on_item_type_and_item_id", using: :btree
|
||||
|
||||
create_table "nameservers", force: true do |t|
|
||||
t.string "hostname"
|
||||
t.string "ipv4"
|
||||
|
@ -211,4 +266,15 @@ ActiveRecord::Schema.define(version: 20141001085322) do
|
|||
t.integer "country_id"
|
||||
end
|
||||
|
||||
create_table "versions", force: true 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 "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue