From b4d100478e8000dbe0e4e5ca921a5ee61b39451e Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 2 Feb 2023 18:55:48 -0500 Subject: [PATCH] paperwork: Include departments with no mailing list in shopleads mailing list --- paperwork/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paperwork/api.py b/paperwork/api.py index d66885a..6369170 100644 --- a/paperwork/api.py +++ b/paperwork/api.py @@ -28,7 +28,7 @@ class DepartmentViewSet(viewsets.ModelViewSet): Generate a mailing list for each department, containing all certified users for tools in that department or child departments """ - departments = self.queryset.filter(has_mailing_list=True).prefetch_related( + departments = self.queryset.prefetch_related( "children", "shop_lead_flag__members", Prefetch( @@ -37,7 +37,7 @@ class DepartmentViewSet(viewsets.ModelViewSet): ), ) lists = {} - for department in departments: + for department in departments.filter(has_mailing_list=True): if department.shop_lead_flag is not None: moderator_emails = { member.email for member in department.shop_lead_flag.members.all() @@ -75,12 +75,12 @@ class DepartmentViewSet(viewsets.ModelViewSet): "members" ] - for department in departments: + for department in departments.filter(has_mailing_list=True): if department.parent_id is None: recurse_children(department) shopleads = {} - for department in departments: + for department in departments.filter(shop_lead_flag__isnull=False): for member in department.shop_lead_flag.members.all(): if member not in shopleads: shopleads[member] = []