Skip to content

Commit 0260293

Browse files
Merge pull request #1412 from IFRCGo/fix/docs-nonetype-to-get
Fix via coreapi/from-documenting-your-api
2 parents 3ca9501 + d3b62bb commit 0260293

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
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):

main/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
url(r'^api/v2/event/(?P<pk>\d+)', api_views.EventViewset.as_view({'get': 'retrieve'})),
194194
url(r'^api/v2/event/(?P<slug>[-\w]+)', api_views.EventViewset.as_view({'get': 'retrieve'}, lookup_field='slug')),
195195
url(r'^api/v2/exportperresults/', per_views.ExportAssessmentToCSVViewset.as_view()),
196-
url(r'^docs/', include_docs_urls(title='IFRC Go API')),
196+
url(r'^docs/', include_docs_urls(title='IFRC Go API', public=False)),
197197
url(r'^tinymce/', include('tinymce.urls')),
198198
url(r'^admin/', RedirectView.as_view(url='/')),
199199
# url(r'^', admin.site.urls),

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)