A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Made filename_to_path a static method
Wolf-Bastian Poettnera45e6c1b48f6
diff --git a/src/documents/models.py b/src/documents/models.pyindex 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 pathos.makedirs(dir_new, exist_ok=True)@propertydef 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