From 4f9fa88bd4be3ac89caf8099ca3226109ce90a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Tue, 22 Sep 2020 16:09:35 +0300 Subject: [PATCH] Registrant: Only show domains that user is connected with personally / via company --- app/models/contact.rb | 11 +++++++---- app/models/registrant_user.rb | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 0eb7fccbd..7ed2d9031 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -210,10 +210,13 @@ class Contact < ApplicationRecord ) end - def registrant_user_contacts(registrant_user) - registrant_user_direct_contacts(registrant_user) - .or(registrant_user_company_contacts(registrant_user)) - .or(registrant_user_indirect_contacts(registrant_user)) + def registrant_user_contacts(registrant_user, representment: true) + represented_contacts = registrant_user_direct_contacts(registrant_user) + .or(registrant_user_company_contacts(registrant_user)) + + return represented_contacts if representment + + represented_contacts.or(registrant_user_indirect_contacts(registrant_user)) end def registrant_user_direct_contacts(registrant_user) diff --git a/app/models/registrant_user.rb b/app/models/registrant_user.rb index e7ce9cc3b..c631c5c8e 100644 --- a/app/models/registrant_user.rb +++ b/app/models/registrant_user.rb @@ -22,8 +22,8 @@ class RegistrantUser < User citizen_country_code: country.alpha3) end - def contacts - Contact.registrant_user_contacts(self) + def contacts(representment: true) + Contact.registrant_user_contacts(self, representment: representment) end def direct_contacts