Fixed deleted report message
This commit is contained in:
parent
7b2c58cb2d
commit
01e1d1ffee
1 changed files with 6 additions and 4 deletions
|
@ -137,7 +137,7 @@ def report_detail(request, report_pk):
|
||||||
# get corresponding sections
|
# get corresponding sections
|
||||||
section_set = Section.objects.filter(report_id=report_pk)
|
section_set = Section.objects.filter(report_id=report_pk)
|
||||||
for i in section_set:
|
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='')
|
field_set = Field.objects.filter(section_id=i.id).exclude(data_file__exact='')
|
||||||
if field_set.exists():
|
if field_set.exists():
|
||||||
for j in field_set:
|
for j in field_set:
|
||||||
|
@ -145,9 +145,11 @@ def report_detail(request, report_pk):
|
||||||
path_name = str(j.data_file)
|
path_name = str(j.data_file)
|
||||||
os.remove(path_name)
|
os.remove(path_name)
|
||||||
# Field.delete_data_file(j, path_name)
|
# Field.delete_data_file(j, path_name)
|
||||||
# delete the full report
|
# delete the full report and catch the title
|
||||||
Report.objects.get(id=report_pk).delete()
|
r = Report.objects.get(id=report_pk)
|
||||||
return JsonResponse({"message": "Deleted report {0}.".format(report_pk)})
|
title = r.title
|
||||||
|
r.delete()
|
||||||
|
return JsonResponse({"message": "Deleted report: {0}.".format(title)})
|
||||||
|
|
||||||
|
|
||||||
# update a section with new data
|
# update a section with new data
|
||||||
|
|
Loading…
Reference in a new issue