mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Merge pull request #1440 from GwynHannay/feature-orig-filename-metadata
Feature: Preserve original filename in metadata
This commit is contained in:
@@ -42,6 +42,7 @@ class DocumentAdmin(admin.ModelAdmin):
|
||||
"checksum",
|
||||
"archive_filename",
|
||||
"archive_checksum",
|
||||
"original_filename",
|
||||
)
|
||||
|
||||
list_display_links = ("title",)
|
||||
|
@@ -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)
|
||||
|
25
src/documents/migrations/1023_document_original_filename.py
Normal file
25
src/documents/migrations/1023_document_original_filename.py
Normal file
@@ -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",
|
||||
),
|
||||
),
|
||||
]
|
@@ -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,
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user