From e7161c7ff91e06c179791acaf05f12074d490a17 Mon Sep 17 00:00:00 2001 From: Rupika Date: Mon, 11 Feb 2019 12:36:24 -0800 Subject: [PATCH] clean up code --- back/backend/models.py | 20 ++------------------ back/backend/views.py | 1 - 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/back/backend/models.py b/back/backend/models.py index 176c080..557020f 100644 --- a/back/backend/models.py +++ b/back/backend/models.py @@ -2,7 +2,6 @@ from django.db import models from django.conf import settings import datetime import ntpath -import os class Report(models.Model): user_id = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) @@ -82,21 +81,6 @@ class Field(models.Model): # function that accommodates if # path has slash at end - def path_leaf(self, path, flag=1): + def path_leaf(self, path): dir_path, name = ntpath.split(path) - if flag == 1: - 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("") - - + return name or ntpath.basename(dir_path) diff --git a/back/backend/views.py b/back/backend/views.py index 457f438..fa17a1b 100644 --- a/back/backend/views.py +++ b/back/backend/views.py @@ -144,7 +144,6 @@ def report_detail(request, report_pk): # delete the file if exists path_name = str(j.data_file) os.remove(path_name) - # Field.delete_data_file(j, path_name) # delete the full report and catch the title r = Report.objects.get(id=report_pk) title = r.title