clean up code
This commit is contained in:
parent
c860ae7000
commit
e7161c7ff9
2 changed files with 2 additions and 19 deletions
|
@ -2,7 +2,6 @@ from django.db import models
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import datetime
|
import datetime
|
||||||
import ntpath
|
import ntpath
|
||||||
import os
|
|
||||||
|
|
||||||
class Report(models.Model):
|
class Report(models.Model):
|
||||||
user_id = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
user_id = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||||
|
@ -82,21 +81,6 @@ class Field(models.Model):
|
||||||
|
|
||||||
# function that accommodates if
|
# function that accommodates if
|
||||||
# path has slash at end
|
# path has slash at end
|
||||||
def path_leaf(self, path, flag=1):
|
def path_leaf(self, path):
|
||||||
dir_path, name = ntpath.split(path)
|
dir_path, name = ntpath.split(path)
|
||||||
if flag == 1:
|
|
||||||
return name or ntpath.basename(dir_path)
|
return name or ntpath.basename(dir_path)
|
||||||
else:
|
|
||||||
return dir_path, name
|
|
||||||
|
|
||||||
# def delete_data_file(self, file_path):
|
|
||||||
# # delete file name in uploads
|
|
||||||
# # os.remove(file_name)
|
|
||||||
# os.remove(file_path)
|
|
||||||
#
|
|
||||||
# # check if directory is empty
|
|
||||||
# # if yes, delete directory
|
|
||||||
# # if [f for f in os.listdir("back/uploads") if not f.startswith('.')] == []:
|
|
||||||
# # os.removedirs("")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,6 @@ def report_detail(request, report_pk):
|
||||||
# delete the file if exists
|
# delete the file if exists
|
||||||
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)
|
|
||||||
# delete the full report and catch the title
|
# delete the full report and catch the title
|
||||||
r = Report.objects.get(id=report_pk)
|
r = Report.objects.get(id=report_pk)
|
||||||
title = r.title
|
title = r.title
|
||||||
|
|
Loading…
Reference in a new issue