diff --git a/gregor_django/gregor_anvil/tests/test_views.py b/gregor_django/gregor_anvil/tests/test_views.py index 017146b7..4e7dbab1 100644 --- a/gregor_django/gregor_anvil/tests/test_views.py +++ b/gregor_django/gregor_anvil/tests/test_views.py @@ -290,6 +290,19 @@ def test_site_user_table(self): self.assertIn(site_user, table.data) self.assertNotIn(non_site_user, table.data) + 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.research_centers.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_link_to_member_group(self): """Response includes a link to the members group if it exists.""" member_group = acm_factories.ManagedGroupFactory.create() @@ -504,6 +517,19 @@ def test_site_user_table(self): self.assertIn(pg_user, table.data) self.assertNotIn(non_pg_user, table.data) + 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.partner_groups.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_table_classes(self): """Table classes are correct.""" obj = self.model_factory.create() diff --git a/gregor_django/gregor_anvil/views.py b/gregor_django/gregor_anvil/views.py index d925ad94..4f251af5 100644 --- a/gregor_django/gregor_anvil/views.py +++ b/gregor_django/gregor_anvil/views.py @@ -48,7 +48,7 @@ def get_tables(self): groupaccountmembership__group=self.object.uploader_group, ) return [ - UserTable(User.objects.filter(research_centers=self.object)), + UserTable(User.objects.filter(is_active=True, research_centers=self.object)), tables.AccountTable(members, exclude=("user__research_centers", "number_groups")), tables.AccountTable(uploaders, exclude=("user__research_centers", "number_groups")), ] @@ -80,7 +80,7 @@ def get_tables(self): groupaccountmembership__group=self.object.uploader_group, ) return [ - UserTable(User.objects.filter(partner_groups=self.object)), + UserTable(User.objects.filter(is_active=True, partner_groups=self.object)), tables.AccountTable(members, exclude=("user__research_centers", "number_groups")), tables.AccountTable(uploaders, exclude=("user__research_centers", "number_groups")), ] diff --git a/requirements/dev-requirements.txt b/requirements/dev-requirements.txt index 0f4bd421..64d63172 100644 --- a/requirements/dev-requirements.txt +++ b/requirements/dev-requirements.txt @@ -44,7 +44,7 @@ dill==0.3.8 # via pylint distlib==0.3.8 # via virtualenv -django==4.2.13 +django==4.2.14 # via # -c requirements/requirements.txt # django-debug-toolbar diff --git a/requirements/requirements.txt b/requirements/requirements.txt index e0908bd6..8d00803a 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -38,7 +38,7 @@ cryptography==42.0.4 # via pyjwt defusedxml==0.7.1 # via python3-openid -django==4.2.13 +django==4.2.14 # via # -r requirements/requirements.in # crispy-bootstrap5