diff --git a/back/backend/views.py b/back/backend/views.py index fac08a4..457f438 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -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