From e48a67b98841fe9e0ed40bd3fcfd0ac965be8fd3 Mon Sep 17 00:00:00 2001 From: Rupika Date: Fri, 15 Feb 2019 14:45:49 -0800 Subject: [PATCH] tweaked section completed boolean and got file functionality working --- back/backend/views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/back/backend/views.py b/back/backend/views.py index 6de2b1e..359589d 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -1,8 +1,10 @@ -from rest_framework.decorators import api_view +from rest_framework.decorators import api_view, parser_classes from django.http import JsonResponse from .models import * from .policy import pol import os +from rest_framework.exceptions import ParseError +from rest_framework.parsers import FileUploadParser, MultiPartParser # function that prints all the reports @@ -233,14 +235,15 @@ def section(request, report_pk, section_pk): complete = section_complete(section_pk) s = Section.objects.get(id=section_pk) if complete: - # s = Section.objects.get(id=section_pk) s.completed = True s.save() + else: + s.completed = False data = { "message": "Updated report {0}, section {1}.".format(report_pk, section_pk), "section completion": s.completed, - "request_data": request.data + "request_data": "{}".format(request.data) } return JsonResponse(data)