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": {