From 3e003bddb73aaf4243c035b627ecb662d931c833 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 9 May 2024 02:22:33 -0400 Subject: [PATCH] paperwork: Fix regression in `Shopleads` mailing list membership --- paperwork/api.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/paperwork/api.py b/paperwork/api.py index 96b17f1..b55350e 100644 --- a/paperwork/api.py +++ b/paperwork/api.py @@ -49,17 +49,12 @@ class DepartmentViewSet(viewsets.ModelViewSet): "shop_lead_flag__members", ) lists: dict[str, MailingList] = {} - shopleads: dict[Member, list[Department]] = {} for department in departments.filter(has_mailing_list=True): if department.shop_lead_flag is not None: moderator_emails = { member.volunteer_email if member.volunteer_email else member.email for member in department.shop_lead_flag.members.all() } - for member in department.shop_lead_flag.members.all(): - if member not in shopleads: - shopleads[member] = [] - shopleads[member].append(department) else: moderator_emails = set() @@ -98,6 +93,13 @@ class DepartmentViewSet(viewsets.ModelViewSet): if department.parent_id is None: recurse_children(department) + shopleads: dict[Member, list[Department]] = {} + 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] = [] + shopleads[member].append(department) + # Add members to the Shop Leads mailing list, but don't configure it lists["ShopLeads"] = { "members": {