mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 10:49:39 +02:00
Basic history display for eedirekt users
This commit is contained in:
parent
b5608c1394
commit
a426862aa8
6 changed files with 104 additions and 15 deletions
19
app/controllers/client/contact_versions_controller.rb
Normal file
19
app/controllers/client/contact_versions_controller.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class Client::ContactVersionsController < ClientController
|
||||
before_action :set_version, only: [:show]
|
||||
|
||||
def index
|
||||
@versions = ContactVersion.registrar_events(current_user.registrar.id)
|
||||
@versions.flatten!
|
||||
end
|
||||
|
||||
def show
|
||||
@event = params[:event]
|
||||
@contact = @version.reify(has_one: true) unless @event == 'create'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_version
|
||||
@version = ContactVersion.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -48,21 +48,6 @@ class Contact < ActiveRecord::Base
|
|||
CONTACT_TYPE_ADMIN = 'admin'
|
||||
CONTACT_TYPES = [CONTACT_TYPE_TECH, CONTACT_TYPE_ADMIN]
|
||||
|
||||
# TEMP Scope until confusion with contact name is sorted out
|
||||
# scope :named, -> { joins(:international_address).uniq.all }
|
||||
|
||||
# TEMP METHOD for transaction to STI
|
||||
#def address
|
||||
# international_address
|
||||
#end
|
||||
##
|
||||
|
||||
#def presence_of_one_address
|
||||
# return true if local_address || international_address
|
||||
# errors.add(:local_address, 'Local or international address must be present')
|
||||
# errors.add(:international_address, 'Local or international address must be present')
|
||||
#end
|
||||
|
||||
def ident_must_be_valid
|
||||
# TODO: Ident can also be passport number or company registry code.
|
||||
# so have to make changes to validations (and doc/schema) accordingly
|
||||
|
|
|
@ -3,4 +3,30 @@ class ContactVersion < PaperTrail::Version
|
|||
|
||||
self.table_name = :contact_versions
|
||||
self.sequence_name = :contact_version_id_seq
|
||||
|
||||
class << self
|
||||
|
||||
def registrar_events(id)
|
||||
registrar = Registrar.find(id)
|
||||
@events = []
|
||||
registrar.users.each { |user| @events << user_contacts(user.id) }
|
||||
registrar.epp_users.each { |user| @events << user_contacts(user.id) }
|
||||
@events
|
||||
end
|
||||
|
||||
def user_events(id, epp_user_id=nil)
|
||||
contacts = []
|
||||
contacts << user_contacts(id)
|
||||
contacts << epp_user_contacts(epp_user_id) if epp_user_id
|
||||
contacts
|
||||
end
|
||||
|
||||
def user_contacts(id)
|
||||
where(whodunnit: id.to_s)
|
||||
end
|
||||
|
||||
def epp_user_contacts(id)
|
||||
where(whodunnit: "#{id}-EppUser")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
33
app/views/client/contact_versions/index.haml
Normal file
33
app/views/client/contact_versions/index.haml
Normal file
|
@ -0,0 +1,33 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs= t('shared.contacts')
|
||||
=# render 'admin/contacts/partials/search'
|
||||
.col-sm-6
|
||||
%h2.text-right.text-center-xs
|
||||
= link_to(t('shared.create_new_contact'), new_client_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'}
|
||||
= t('shared.event')
|
||||
%th{class: 'col-xs-2'}
|
||||
= t('shared.whodunnit')
|
||||
%th{class: 'col-xs-2'}
|
||||
= t('shared.created_at')
|
||||
%th{class: 'col-xs-1'}
|
||||
= t('shared.details')
|
||||
=# sort_link(@q, 'email', t('shared.email'))
|
||||
%tbody
|
||||
- @versions.each do |x|
|
||||
%tr
|
||||
%td= x.event
|
||||
%td= x.whodunnit
|
||||
%td= l(x.created_at, format: :short)
|
||||
%td= link_to(t('shared.details'), client_contact_version_path(x, event: x.event))
|
||||
.row
|
||||
.col-md-12
|
||||
=# paginate @contacts
|
24
app/views/client/contact_versions/show.haml
Normal file
24
app/views/client/contact_versions/show.haml
Normal file
|
@ -0,0 +1,24 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h2.text-center-xs= t('shared.contacts')
|
||||
%hr
|
||||
.row
|
||||
.col-sm-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t('shared.version')
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t('shared.whodunnit')
|
||||
%dd= @version.whodunnit
|
||||
%dt= t('shared.event')
|
||||
%dd= @version.event
|
||||
%dt= t('shared.created_at')
|
||||
%dd= l(@version.created_at, format: :short)
|
||||
- if @event != 'create' && @contact.address
|
||||
- # TODO fix address not being available with reify
|
||||
= render 'admin/contacts/partials/address'
|
||||
|
||||
|
||||
|
||||
.col-sm-6= render 'admin/contacts/partials/general' unless @event == 'create'
|
|
@ -48,6 +48,8 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :contact_versions
|
||||
|
||||
root 'domains#index'
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue