diff --git a/docs/advanced_usage.rst b/docs/advanced_usage.rst index ba5b3cbaa..7709da1c9 100644 --- a/docs/advanced_usage.rst +++ b/docs/advanced_usage.rst @@ -171,6 +171,7 @@ into paperless. It receives the following environment variables: * ``DOCUMENT_THUMBNAIL_URL`` * ``DOCUMENT_CORRESPONDENT`` * ``DOCUMENT_TAGS`` +* ``DOCUMENT_ORIGINAL_FILENAME`` The script can be in any language, but for a simple shell script example, you can take a look at `post-consumption-example.sh`_ in this project. diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index c79413a4b..b17b0ee10 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -816,7 +816,7 @@ src/app/components/document-detail/document-detail.component.html - 174 + 178 src/app/components/document-list/save-view-config-dialog/save-view-config-dialog.component.html @@ -1570,78 +1570,85 @@ 113 + + Original filename + + src/app/components/document-detail/document-detail.component.html + 117 + + Original MD5 checksum src/app/components/document-detail/document-detail.component.html - 117 + 121 Original file size src/app/components/document-detail/document-detail.component.html - 121 + 125 Original mime type src/app/components/document-detail/document-detail.component.html - 125 + 129 Archive MD5 checksum src/app/components/document-detail/document-detail.component.html - 129 + 133 Archive file size src/app/components/document-detail/document-detail.component.html - 133 + 137 Original document metadata src/app/components/document-detail/document-detail.component.html - 139 + 143 Archived document metadata src/app/components/document-detail/document-detail.component.html - 140 + 144 Enter Password src/app/components/document-detail/document-detail.component.html - 162 + 166 src/app/components/document-detail/document-detail.component.html - 192 + 196 Discard src/app/components/document-detail/document-detail.component.html - 172 + 176 Save & next src/app/components/document-detail/document-detail.component.html - 173 + 177 diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index 6c8fc463f..764a587e0 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -113,6 +113,10 @@ Media filename {{metadata?.media_filename}} + + Original filename + {{metadata?.original_filename}} + Original MD5 checksum {{metadata?.original_checksum}} diff --git a/src-ui/src/app/data/paperless-document-metadata.ts b/src-ui/src/app/data/paperless-document-metadata.ts index 1f9155b3a..152f69046 100644 --- a/src-ui/src/app/data/paperless-document-metadata.ts +++ b/src-ui/src/app/data/paperless-document-metadata.ts @@ -7,5 +7,7 @@ export interface PaperlessDocumentMetadata { media_filename?: string + original_filename?: string + has_archive_version?: boolean } diff --git a/src/documents/admin.py b/src/documents/admin.py index 3e3f1eb1c..6fa06c49b 100644 --- a/src/documents/admin.py +++ b/src/documents/admin.py @@ -42,6 +42,7 @@ class DocumentAdmin(admin.ModelAdmin): "checksum", "archive_filename", "archive_checksum", + "original_filename", ) list_display_links = ("title",) diff --git a/src/documents/consumer.py b/src/documents/consumer.py index 69a9efb48..d1b01290a 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -203,6 +203,7 @@ class Consumer(LoggingMixin): script_env["DOCUMENT_TAGS"] = str( ",".join(document.tags.all().values_list("name", flat=True)), ) + script_env["DOCUMENT_ORIGINAL_FILENAME"] = str(document.original_filename) try: Popen( @@ -475,6 +476,7 @@ class Consumer(LoggingMixin): created=create_date, modified=create_date, storage_type=storage_type, + original_filename=self.filename, ) self.apply_overrides(document) diff --git a/src/documents/migrations/1023_document_original_filename.py b/src/documents/migrations/1023_document_original_filename.py new file mode 100644 index 000000000..065956bd9 --- /dev/null +++ b/src/documents/migrations/1023_document_original_filename.py @@ -0,0 +1,25 @@ +# Generated by Django 4.0.6 on 2022-07-25 06:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("documents", "1022_paperlesstask"), + ] + + operations = [ + migrations.AddField( + model_name="document", + name="original_filename", + field=models.CharField( + default=None, + editable=False, + help_text="The original name of the file when it was uploaded", + max_length=1024, + null=True, + verbose_name="original filename", + ), + ), + ] diff --git a/src/documents/models.py b/src/documents/models.py index d8e02e570..f6df273ad 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -214,6 +214,16 @@ class Document(models.Model): help_text=_("Current archive filename in storage"), ) + original_filename = models.CharField( + _("original filename"), + max_length=1024, + editable=False, + default=None, + unique=False, + null=True, + help_text=_("The original name of the file when it was uploaded"), + ) + archive_serial_number = models.IntegerField( _("archive serial number"), blank=True, diff --git a/src/documents/views.py b/src/documents/views.py index 84fc38a38..b261f37fd 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -313,6 +313,7 @@ class DocumentViewSet( "original_metadata": self.get_metadata(doc.source_path, doc.mime_type), "archive_checksum": doc.archive_checksum, "archive_media_filename": doc.archive_filename, + "original_filename": doc.original_filename, } if doc.has_archive_version: