A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Tweak the import/export system to handle encryption choices better
Daniel Quinn090565d84c6d
diff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.pyindex fce09092c..42a514348 100644--- a/src/documents/management/commands/document_exporter.py+++ b/src/documents/management/commands/document_exporter.py@@ -55,7 +55,12 @@ class Command(Renderable, BaseCommand):documents = Document.objects.all()document_map = {d.pk: d for d in documents}manifest = json.loads(serializers.serialize("json", documents))- for document_dict in manifest:++ for index, document_dict in enumerate(manifest):++ # Force output to unencrypted as that will be the current state.+ # The importer will make the decision to encrypt or not.+ manifest[index]["fields"]["storage_type"] = Document.STORAGE_TYPE_UNENCRYPTED # NOQA: E501document = document_map[document_dict["pk"]]diff --git a/src/documents/management/commands/document_importer.py b/src/documents/management/commands/document_importer.pyindex 15401722c..ae5c1853f 100644--- a/src/documents/management/commands/document_importer.py+++ b/src/documents/management/commands/document_importer.py@@ -94,7 +94,7 @@ class Command(Renderable, BaseCommand):document_path = os.path.join(self.source, doc_file)thumbnail_path = os.path.join(self.source, thumb_file)- if document.storage_type == Document.STORAGE_TYPE_GPG:+ if settings.PASSPHRASE:with open(document_path, "rb") as unencrypted:with open(document.source_path, "wb") as encrypted:@@ -112,3 +112,15 @@ class Command(Renderable, BaseCommand):shutil.copy(document_path, document.source_path)shutil.copy(thumbnail_path, document.thumbnail_path)++ # Reset the storage type to whatever we've used while importing++ storage_type = Document.STORAGE_TYPE_UNENCRYPTED+ if settings.PASSPHRASE:+ storage_type = Document.STORAGE_TYPE_GPG++ Document.objects.filter(+ pk__in=[r["pk"] for r in self.manifest]+ ).update(+ storage_type=storage_type+ )