A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Use relatives paths instead of absolutes paths for document export/import
CkuT22c8049bed87
diff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.pyindex f7a06139e..41838b182 100644--- a/src/documents/management/commands/document_exporter.py+++ b/src/documents/management/commands/document_exporter.py@@ -62,17 +62,20 @@ class Command(Renderable, BaseCommand):document = document_map[document_dict["pk"]]- target = os.path.join(self.target, document.file_name)- thumbnail_target = target + "-tumbnail.png"- document_dict[EXPORTER_FILE_NAME] = target- document_dict[EXPORTER_THUMBNAIL_NAME] = thumbnail_target+ file_target = os.path.join(self.target, document.file_name)- print("Exporting: {}".format(target))+ thumbnail_name = document.file_name + "-tumbnail.png"+ thumbnail_target = os.path.join(self.target, thumbnail_name)++ document_dict[EXPORTER_FILE_NAME] = document.file_name+ document_dict[EXPORTER_THUMBNAIL_NAME] = thumbnail_name++ print("Exporting: {}".format(file_target))t = int(time.mktime(document.created.timetuple()))- with open(target, "wb") as f:+ with open(file_target, "wb") as f:f.write(GnuPG.decrypted(document.source_file))- os.utime(target, times=(t, t))+ os.utime(file_target, times=(t, t))with open(thumbnail_target, "wb") as f:f.write(GnuPG.decrypted(document.thumbnail_file))diff --git a/src/documents/management/commands/document_importer.py b/src/documents/management/commands/document_importer.pyindex a2a496edf..a89f0d4ef 100644--- a/src/documents/management/commands/document_importer.py+++ b/src/documents/management/commands/document_importer.py@@ -79,7 +79,7 @@ class Command(Renderable, BaseCommand):)doc_file = record[EXPORTER_FILE_NAME]- if not os.path.exists(doc_file):+ if not os.path.exists(os.path.join(self.source, doc_file)):raise CommandError('The manifest file refers to "{}" which does not ''appear to be in the source directory.'.format(doc_file)@@ -96,13 +96,16 @@ class Command(Renderable, BaseCommand):thumb_file = record[EXPORTER_THUMBNAIL_NAME]document = Document.objects.get(pk=record["pk"])- with open(doc_file, "rb") as unencrypted:+ document_path = os.path.join(self.source, doc_file)+ thumbnail_path = os.path.join(self.source, thumb_file)++ with open(document_path, "rb") as unencrypted:with open(document.source_path, "wb") as encrypted:print("Encrypting {} and saving it to {}".format(doc_file, document.source_path))encrypted.write(GnuPG.encrypted(unencrypted))- with open(thumb_file, "rb") as unencrypted:+ with open(thumbnail_path, "rb") as unencrypted:with open(document.thumbnail_path, "wb") as encrypted:print("Encrypting {} and saving it to {}".format(thumb_file, document.thumbnail_path))