From a45e6c1b48f66321f81d0ecdfa9eee156c30cb66 Mon Sep 17 00:00:00 2001 From: Wolf-Bastian Poettner Date: Sat, 1 Feb 2020 14:18:33 +0000 Subject: [PATCH] Made filename_to_path a static method --- src/documents/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/documents/models.py b/src/documents/models.py index c20ecb93a..d016c32e7 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -341,16 +341,17 @@ class Document(models.Model): new_filename = self.generate_source_filename() # Determine the full "target" path - dir_new = self.filename_to_path(os.path.dirname(new_filename)) + dir_new = Document.filename_to_path(os.path.dirname(new_filename)) # Create new path os.makedirs(dir_new, exist_ok=True) @property def source_path(self): - return self.filename_to_path(self.source_filename) + return Document.filename_to_path(self.source_filename) - def filename_to_path(self, filename): + @staticmethod + def filename_to_path(filename): return os.path.join( settings.MEDIA_ROOT, "documents", @@ -393,7 +394,7 @@ class Document(models.Model): return reverse("fetch", kwargs={"kind": "thumb", "pk": self.pk}) def set_filename(self, filename): - if os.path.isfile(self.filename_to_path(filename)): + if os.path.isfile(Document.filename_to_path(filename)): self.filename = filename