Fixed deleted report message

This commit is contained in:
Rupika 2019-02-10 19:59:28 -08:00
parent 7b2c58cb2d
commit 01e1d1ffee

View file

@ -137,7 +137,7 @@ def report_detail(request, report_pk):
# get corresponding sections
section_set = Section.objects.filter(report_id=report_pk)
for i in section_set:
# gets the fields that have a field in them
# gets the fields that only have a data file in them
field_set = Field.objects.filter(section_id=i.id).exclude(data_file__exact='')
if field_set.exists():
for j in field_set:
@ -145,9 +145,11 @@ def report_detail(request, report_pk):
path_name = str(j.data_file)
os.remove(path_name)
# Field.delete_data_file(j, path_name)
# delete the full report
Report.objects.get(id=report_pk).delete()
return JsonResponse({"message": "Deleted report {0}.".format(report_pk)})
# delete the full report and catch the title
r = Report.objects.get(id=report_pk)
title = r.title
r.delete()
return JsonResponse({"message": "Deleted report: {0}.".format(title)})
# update a section with new data