revamped update logic -- updated dummy JSON to mirror a full report

This commit is contained in:
Rupika 2019-02-13 17:41:28 -08:00
parent b2088291df
commit 11b1de72b3
2 changed files with 21 additions and 15 deletions

View file

@ -155,7 +155,12 @@ def report_detail(request, report_pk):
# update a section with new data
@api_view(['PUT'])
def section(request, report_pk, section_pk):
for v in request.data["fields"]:
# first enter sections
for s in request.data["sections"]:
# check for match
if s["id"] == section_pk:
# begin updating fields
for v in s["fields"]:
update_field = Field.objects.get(id=v["id"])
if v["type"] == "boolean":
@ -174,3 +179,4 @@ def section(request, report_pk, section_pk):
update_field.save()
return JsonResponse({"message": "Updated report {0}, section {1}.".format(report_pk, section_pk)})

Binary file not shown.