Skip to content

Commit

Permalink
Merge pull request #652 from UW-GAC/bugfix/hide-inactive-users-on-stu…
Browse files Browse the repository at this point in the history
…dy-site-table

Hide inactive users in study site table
  • Loading branch information
amstilp authored Jul 11, 2024
2 parents c3e47c5 + bdfe771 commit 548b2c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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

0 comments on commit 548b2c9

Please sign in to comment.