From 3af9f51fb080b38837e5c03883a8a43e51a66bb4 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 21 Jan 2020 05:00:45 +0000 Subject: [PATCH] Misc fixes --- apiserver/apiserver/api/utils.py | 6 ++++-- apiserver/apiserver/api/views.py | 3 ++- apiserver/apiserver/settings.py | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apiserver/apiserver/api/utils.py b/apiserver/apiserver/api/utils.py index d2f99b7..850e098 100644 --- a/apiserver/apiserver/api/utils.py +++ b/apiserver/apiserver/api/utils.py @@ -89,8 +89,10 @@ def tally_membership_months(member, fake_date=None): start_date = member.current_start_date if not start_date: return False - txs = models.Transaction.objects.filter(member_id=member.id) - txs = txs.filter(date__gte=start_date) + txs = models.Transaction.objects.filter( + member_id=member.id, + date__gte=start_date, + ) total_months_agg = txs.aggregate(Sum('number_of_membership_months')) total_months = total_months_agg['number_of_membership_months__sum'] or 0 diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index b2335cf..3a11ed1 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -107,13 +107,14 @@ class SearchViewSet(Base, Retrieve): result_objects = [queryset.get(id=x) for x in result_ids] queryset = result_objects - else: + elif self.action == 'create': gen_search_strings() # update cache queryset = queryset.order_by('-vetted_date') return queryset # must POST so query string doesn't change so preflight request is cached + # to save an OPTIONS request so search is fast def create(self, request): try: seq = int(request.data.get('seq', 0)) diff --git a/apiserver/apiserver/settings.py b/apiserver/apiserver/settings.py index ec5d90f..885f5a3 100644 --- a/apiserver/apiserver/settings.py +++ b/apiserver/apiserver/settings.py @@ -39,6 +39,8 @@ if DEBUG: 'api.spaceport.dns.t0.vc', ] +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + # Application definition