mirror of
https://github.com/internetee/registry.git
synced 2025-07-04 18:23:35 +02:00
Unified contact and domain versions under client
This commit is contained in:
parent
582fd59090
commit
871e289973
4 changed files with 6 additions and 29 deletions
|
@ -2,7 +2,7 @@ class Client::ContactVersionsController < ClientController
|
|||
before_action :set_version, only: [:show]
|
||||
|
||||
def index
|
||||
@versions = ContactVersion.registrar_events(current_user.registrar.id)
|
||||
@versions = ContactVersion.registrar_events(current_registrar.id)
|
||||
@versions.flatten!
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ class Client::DomainVersionsController < ClientController
|
|||
before_action :set_version, only: [:show]
|
||||
|
||||
def index
|
||||
@versions = DomainVersion.registrar_events(current_user.registrar.id)
|
||||
@versions = DomainVersion.registrar_events(current_registrar.id)
|
||||
@versions.flatten!
|
||||
end
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ module UserEvents
|
|||
module ClassMethods
|
||||
def registrar_events(id)
|
||||
registrar = Registrar.find(id)
|
||||
return nil unless registrar
|
||||
return [] unless registrar
|
||||
@events = []
|
||||
registrar.users.each { |user| @events << user_events(user.id) }
|
||||
registrar.epp_users.each { |user| @events << user_events(user.id) }
|
||||
registrar.epp_users.each { |user| @events << epp_user_events(user.id) }
|
||||
@events
|
||||
end
|
||||
|
||||
|
|
|
@ -1,32 +1,9 @@
|
|||
class ContactVersion < PaperTrail::Version
|
||||
include UserEvents
|
||||
|
||||
scope :deleted, -> { where(event: 'destroy') }
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue