From 1aa0bd60140c2d363791c6d120a3564eb25c2e32 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 26 Aug 2023 20:20:05 -0400 Subject: [PATCH] paperwork: Add deskers mailing list --- paperwork/api.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/paperwork/api.py b/paperwork/api.py index 850fb9a..c346fd8 100644 --- a/paperwork/api.py +++ b/paperwork/api.py @@ -1,5 +1,5 @@ -from django.db.models import Prefetch from rest_framework import routers, serializers, viewsets +from django.db.models import Prefetch, Q from rest_framework.decorators import action from rest_framework.response import Response @@ -98,6 +98,21 @@ class DepartmentViewSet(viewsets.ModelViewSet): }, } + # TODO: this isn't really in the domain of the `paperwork` app... + deskers = ( + Member.objects.with_is_active() + .filter(is_active=True) + .filter( + Member.objects.has_flag("label", "Volunteer: Desker") + | Q(billing_method__startswith="Desker") + ) + ) + lists["Deskers"] = { + "members": { + desker.sanitized_mailbox(use_volunteer=True) for desker in deskers + } + } + return Response(lists)