Skip to content

Commit d3b62bb

Browse files
committed
Log-noising issues + allowing /docs/ to post
1 parent 9b8dba8 commit d3b62bb

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

lang/permissions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ def has_permission(self, request, view):
1212
# so we'll always allow GET, HEAD or OPTIONS requests. (`view` is allowed for all)
1313
if request.method in permissions.SAFE_METHODS:
1414
return True
15+
if request.method == 'POST' and \
16+
hasattr(request, '_request') and request.path == '/docs/' and \
17+
hasattr(view, 'basename') and view.basename == 'language':
18+
return True
1519
return String.has_perm(request.user, view.kwargs['pk'])
1620

1721
def has_object_permission(self, request, view, obj):

notifications/drf_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime, timedelta
1+
from datetime import datetime, timedelta, timezone
22
from django.db.models import Q
33
from django_filters import rest_framework as filters
44
from rest_framework.authentication import TokenAuthentication
@@ -41,7 +41,7 @@ def get_serializer_class(self):
4141
def get_queryset(self):
4242
limit = 14 # days
4343
cond1 = Q(is_stood_down=True)
44-
cond2 = Q(end__lt=datetime.now()-timedelta(days=limit))
44+
cond2 = Q(end__lt=datetime.utcnow().replace(tzinfo=timezone.utc)-timedelta(days=limit))
4545
return SurgeAlert.objects.exclude(cond1 & cond2)
4646

4747

per/drf_views.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ def get_queryset(self):
338338

339339
class GlobalPreparednessViewset(viewsets.ReadOnlyModelViewSet):
340340
"""Global Preparedness Highlights"""
341+
# Probably not used. E.g. no 'code' in Form
341342
queryset = Form.objects.all()
342343
authentication_classes = (TokenAuthentication,)
343344
permission_classes = (IsAuthenticated,)
@@ -351,13 +352,13 @@ def get_queryset(self):
351352
last_duedate = tmz.localize(datetime(2000, 11, 15, 9, 59, 25, 0))
352353
if not next_duedate:
353354
next_duedate = tmz.localize(datetime(2222, 11, 15, 9, 59, 25, 0))
354-
queryset = FormData.objects.filter(form__updated_at__gt=last_duedate, selected_option=7).select_related('form')
355+
queryset = FormData.objects.filter(form__updated_at__gt=last_duedate, selected_answer_id=7).select_related('form')
355356
result = []
356-
for i in queryset:
357-
j = {'id': i.form.id}
358-
j.update({'code': i.form.code})
359-
j.update({'question_id': i.question_id})
360-
result.append(j)
357+
# for i in queryset:
358+
# j = {'id': i.form.id}
359+
# j.update({'code': i.form.code})
360+
# j.update({'question_id': i.question_id})
361+
# result.append(j)
361362
return result
362363

363364

0 commit comments

Comments
 (0)