From 8561ed2ff4ceaa7f0dfb8272abc6d990f460f566 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 12 Jul 2020 03:09:24 +0000 Subject: [PATCH] Add an API route for members ready to be vetted --- apiserver/apiserver/api/views.py | 16 ++++++++++++++++ apiserver/apiserver/urls.py | 1 + 2 files changed, 17 insertions(+) diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index 72102c0..17579fe 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -509,6 +509,22 @@ class HistoryViewSet(Base, List, Retrieve): return queryset.order_by('-history_date')[:50] +class VettingViewSet(Base, List): + permission_classes = [AllowMetadata | IsAdmin] + serializer_class = serializers.AdminMemberSerializer + + def get_queryset(self): + queryset = models.Member.objects + + four_weeks_ago = utils.today_alberta_tz() - datetime.timedelta(days=28) + queryset = queryset.filter(status__in=['Current', 'Due']) + queryset = queryset.filter(paused_date__isnull=True) + queryset = queryset.filter(vetted_date__isnull=True) + queryset = queryset.filter(current_start_date__lte=four_weeks_ago) + + return queryset.order_by('-current_start_date') + + class RegistrationView(RegisterView): serializer_class = serializers.MyRegisterSerializer diff --git a/apiserver/apiserver/urls.py b/apiserver/apiserver/urls.py index 3b7faa2..b4839fd 100644 --- a/apiserver/apiserver/urls.py +++ b/apiserver/apiserver/urls.py @@ -19,6 +19,7 @@ router.register(r'search', views.SearchViewSet, basename='search') router.register(r'members', views.MemberViewSet, basename='members') router.register(r'courses', views.CourseViewSet, basename='course') router.register(r'history', views.HistoryViewSet, basename='history') +router.register(r'vetting', views.VettingViewSet, basename='vetting') router.register(r'sessions', views.SessionViewSet, basename='session') router.register(r'training', views.TrainingViewSet, basename='training') router.register(r'transactions', views.TransactionViewSet, basename='transaction')