revamped update logic -- updated dummy JSON to mirror a full report
This commit is contained in:
parent
b2088291df
commit
11b1de72b3
2 changed files with 21 additions and 15 deletions
|
@ -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)})
|
||||
|
||||
|
|
BIN
back/db.sqlite3
BIN
back/db.sqlite3
Binary file not shown.
Loading…
Reference in a new issue