mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-10-20 03:06:10 -05:00
Feature: Enhanced templating for filename format (#7836)
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
36
src/documents/migrations/1055_alter_storagepath_path.py
Normal file
36
src/documents/migrations/1055_alter_storagepath_path.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Generated by Django 5.1.1 on 2024-10-03 14:47
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
from django.db import models
|
||||
from django.db import transaction
|
||||
from filelock import FileLock
|
||||
|
||||
from documents.templating.utils import convert_format_str_to_template_format
|
||||
|
||||
|
||||
def convert_from_format_to_template(apps, schema_editor):
|
||||
StoragePath = apps.get_model("documents", "StoragePath")
|
||||
|
||||
with transaction.atomic(), FileLock(settings.MEDIA_LOCK):
|
||||
for storage_path in StoragePath.objects.all():
|
||||
storage_path.path = convert_format_str_to_template_format(storage_path.path)
|
||||
storage_path.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("documents", "1054_customfieldinstance_value_monetary_amount_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="storagepath",
|
||||
name="path",
|
||||
field=models.CharField(max_length=2048, verbose_name="path"),
|
||||
),
|
||||
migrations.RunPython(
|
||||
convert_from_format_to_template,
|
||||
migrations.RunPython.noop,
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user