Deleted contacts and domains list

This commit is contained in:
Andres Keskküla 2014-09-30 10:19:54 +03:00
parent a41505e319
commit f94dccfaa4
10 changed files with 88 additions and 5 deletions

View file

@ -0,0 +1,6 @@
class Admin::ContactHistoriesController < AdminController
def index
@q = ContactVersion.deleted.search(params[:q])
@contacts = @q.result.page(params[:page])
end
end

View file

@ -0,0 +1,6 @@
class Admin::DomainHistoriesController < AdminController
def index
@q = DomainVersion.deleted.search(params[:q])
@domains = @q.result.page(params[:page])
end
end

View file

@ -34,7 +34,7 @@ class Contact < ActiveRecord::Base
delegate :zip, to: :address#, prefix: true delegate :zip, to: :address#, prefix: true
# archiving # archiving
has_paper_trail class_name: 'AddressVersion' has_paper_trail class_name: 'ContactVersion'
IDENT_TYPE_ICO = 'ico' IDENT_TYPE_ICO = 'ico'
IDENT_TYPES = [ IDENT_TYPES = [

View file

@ -1,4 +1,6 @@
class ContactVersion < PaperTrail::Version class ContactVersion < PaperTrail::Version
scope :deleted, -> { where(event: 'destroy') }
self.table_name = :contact_versions self.table_name = :contact_versions
self.sequence_name = :contact_version_id_seq self.sequence_name = :contact_version_id_seq
end end

View file

@ -1,4 +1,6 @@
class DomainVersion < PaperTrail::Version class DomainVersion < PaperTrail::Version
scope :deleted, -> { where(event: 'destroy') }
self.table_name = :domain_versions self.table_name = :domain_versions
self.sequence_name = :domain_version_id_seq self.sequence_name = :domain_version_id_seq
end end

View file

@ -0,0 +1,31 @@
.row
.col-md-12
%h2= t('shared.contacts')
%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-2'}
deleted_at
%tbody
- @contacts.each do |version|
- contact = version.reify
- next unless contact
%tr
%td= contact.name #link_to(x, admin_contact_path(x))
%td= contact.code #link_to(x, admin_contact_path(x))
%td= version.whodunnit if version
%td= version.created_at if version
.row
.col-md-12
= paginate @contacts

View file

@ -4,7 +4,7 @@
= render 'admin/contacts/partials/search' = render 'admin/contacts/partials/search'
.col-sm-6 .col-sm-6
%h2.text-right.text-center-xs %h2.text-right.text-center-xs
= link_to(t('shared.add'), new_admin_contact_path, class: 'btn btn-primary') = link_to(t('shared.deleted'), admin_contact_versions_path(deleted: true), class: 'btn btn-primary')
%hr %hr
.row .row
.col-md-12 .col-md-12

View file

@ -0,0 +1,29 @@
.row
.col-md-12
%h2= 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', t('shared.name'))
%th{class: 'col-xs-1'}
whodunnit
= #sort_link(@q, 'ident', t('shared.identity_code'))
%th{class: 'col-xs-2'}
deleted_at
%tbody
- @domains.each do |version|
- domain = version.reify
- next unless domain
%tr
%td= domain.name #link_to(x, admin_contact_path(x))
%td= domain.status #link_to(x, admin_contact_path(x))
%td= version.whodunnit if version
%td= version.created_at if version
.row
.col-md-12
= paginate @domains

View file

@ -51,10 +51,15 @@
%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'), admin_domain_versions_path = link_to t('shared.versions'), admin_domain_versions_path
%li
= link_to t('shared.deleted'), admin_domain_histories_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.versions'), admin_contact_versions_path
%li
= link_to t('shared.deleted'), admin_contact_histories_path
%ul.nav.navbar-nav.navbar-right %ul.nav.navbar-nav.navbar-right
%li= link_to t('shared.log_out', user: current_user), '/logout' %li= link_to t('shared.log_out', user: current_user), '/logout'

View file

@ -24,9 +24,11 @@ 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 :domain_versions resources :domain_versions
resources :contact_histories
resources :domain_histories
root 'domains#index' root 'domains#index'
end end