Fix Code Formatting
This commit is contained in:
parent
4f398c8e6f
commit
ad77eaaa9e
@ -8,9 +8,9 @@ from django.conf import settings
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils import timezone
|
||||
|
||||
from documents.models import Document
|
||||
from documents.models import CustomField
|
||||
from documents.models import CustomFieldInstance
|
||||
from documents.models import Document
|
||||
|
||||
logger = logging.getLogger("paperless.filehandling")
|
||||
|
||||
@ -197,7 +197,10 @@ def generate_filename(
|
||||
local_added = timezone.localdate(doc.added)
|
||||
local_created = timezone.localdate(doc.created)
|
||||
placeholders = {
|
||||
"title":pathvalidate.sanitize_filename(doc.title, replacement_text="-"),
|
||||
"title": pathvalidate.sanitize_filename(
|
||||
doc.title,
|
||||
replacement_text="-",
|
||||
),
|
||||
"correspondent": correspondent,
|
||||
"document_type": document_type,
|
||||
"created": local_created.isoformat(),
|
||||
@ -223,10 +226,12 @@ def generate_filename(
|
||||
}
|
||||
|
||||
for field in CustomField.objects.all():
|
||||
placeholders['customfield' + f'{field.pk}'] = '-none-'
|
||||
placeholders["customfield" + f"{field.pk}"] = no_value_default
|
||||
|
||||
for field_instance in CustomFieldInstance.objects.filter(document=doc):
|
||||
placeholders['customfield' + f'{field_instance.field.id}'] = field_instance.value
|
||||
placeholders["customfield" + f"{field_instance.field.id}"] = (
|
||||
field_instance.value,
|
||||
)
|
||||
|
||||
path = filename_format.format(**placeholders).strip()
|
||||
if settings.FILENAME_FORMAT_REMOVE_NONE:
|
||||
|
@ -1169,11 +1169,11 @@ class StoragePathSerializer(MatchingModelSerializer, OwnedObjectSerializer):
|
||||
"tag_list": "tag_list",
|
||||
"owner_username": "someone",
|
||||
"original_name": "testfile",
|
||||
"doc_pk":"doc_pk"
|
||||
"doc_pk": "doc_pk",
|
||||
}
|
||||
|
||||
for field in CustomField.objects.all():
|
||||
placeholders['customfield' + f'{field.pk}'] = '-none-'
|
||||
placeholders["customfield" + f"{field.pk}"] = "-none-"
|
||||
|
||||
path.format(**placeholders)
|
||||
except KeyError as err:
|
||||
|
@ -383,6 +383,7 @@ def update_custom_field_instance(sender, instance: CustomFieldInstance, **kwargs
|
||||
doc = Document.objects.get(pk=instance.document.pk)
|
||||
update_filename_and_move_files(sender, doc)
|
||||
|
||||
|
||||
@receiver(models.signals.m2m_changed, sender=Document.tags.through)
|
||||
@receiver(models.signals.post_save, sender=Document)
|
||||
def update_filename_and_move_files(sender, instance: Document, **kwargs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user