Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide inactive users in study site table #652

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions primed/primed_anvil/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,19 @@ def test_site_user_table_when_member_group_is_set(self):
self.assertIsInstance(table, tables.UserAccountSingleGroupMembershipTable)
self.assertEqual(table.managed_group, member_group)

def test_site_user_table_does_not_include_inactive_users(self):
"""Site user table does not include inactive users."""
obj = self.model_factory.create()
inactive_site_user = UserFactory.create()
inactive_site_user.study_sites.set([obj])
inactive_site_user.is_active = False
inactive_site_user.save()
self.client.force_login(self.user)
response = self.client.get(self.get_url(obj.pk))
table = response.context_data["tables"][0]
self.assertEqual(len(table.rows), 0)
self.assertNotIn(inactive_site_user, table.data)

def test_member_group_table(self):
member_group = ManagedGroupFactory.create()
obj = self.model_factory.create(member_group=member_group)
Expand Down
2 changes: 1 addition & 1 deletion primed/primed_anvil/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class StudySiteDetail(AnVILConsortiumManagerStaffViewRequired, MultiTableMixin,
model = models.StudySite

def get_tables(self):
user_qs = User.objects.filter(study_sites=self.object)
user_qs = User.objects.filter(is_active=True, study_sites=self.object)
if self.object.member_group:
user_table = tables.UserAccountSingleGroupMembershipTable(user_qs, managed_group=self.object.member_group)
else:
Expand Down