From 7335ab2fcb8d6f6019e5f56370d3e64c4c5229fe Mon Sep 17 00:00:00 2001 From: Katrina Nguyen <71999631+katrinan029@users.noreply.github.com> Date: Tue, 21 Jan 2025 10:46:02 -0800 Subject: [PATCH] feat: exclude unlinked member records from enterprise (#2317) --- CHANGELOG.rst | 4 ++++ enterprise/__init__.py | 2 +- enterprise/api/v1/views/enterprise_customer_members.py | 5 ++++- enterprise/models.py | 5 ++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 23c5a98a2..42dd8424e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,10 @@ Unreleased ---------- * nothing unreleased +[5.6.3] +-------- +* feat: exclude unlinked member records from enterprise-customer-members and enterprise_group endpoints + [5.6.2] -------- * fix: Add dry_run_mode_enabled field to SAP admin panel diff --git a/enterprise/__init__.py b/enterprise/__init__.py index c283d5e50..a613a3380 100644 --- a/enterprise/__init__.py +++ b/enterprise/__init__.py @@ -2,4 +2,4 @@ Your project description goes here. """ -__version__ = "5.6.2" +__version__ = "5.6.3" diff --git a/enterprise/api/v1/views/enterprise_customer_members.py b/enterprise/api/v1/views/enterprise_customer_members.py index 4a41965cc..e850de6d0 100644 --- a/enterprise/api/v1/views/enterprise_customer_members.py +++ b/enterprise/api/v1/views/enterprise_customer_members.py @@ -102,7 +102,10 @@ def get_members(self, request, *args, **kwargs): FROM enterprise_enterprisecustomeruser ecu INNER JOIN auth_user as au on ecu.user_id = au.id LEFT JOIN auth_userprofile as aup on au.id = aup.user_id - WHERE ecu.enterprise_customer_id = %s + WHERE + ecu.enterprise_customer_id = %s + AND + ecu.linked = 1 ) SELECT * FROM users {user_query_filter} ORDER BY full_name; """ try: diff --git a/enterprise/models.py b/enterprise/models.py index 0eaa1f889..5d588eac3 100644 --- a/enterprise/models.py +++ b/enterprise/models.py @@ -4707,7 +4707,10 @@ def _get_filtered_ecu_ids(self, user_query): from enterprise_enterprisecustomeruser ecu inner join auth_user au on ecu.user_id = au.id left join auth_userprofile aup on au.id = aup.user_id - where ecu.enterprise_customer_id = %s + where + ecu.enterprise_customer_id = %s + and + ecu.linked = 1 ) select id from users where email like %s or full_name like %s; """ # Raw sql is picky about uuid format