mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Fix: Make customfieldinstance soft delete, fix filepath when deleted (#8067)
This commit is contained in:
parent
28fdb170bf
commit
79092c27c5
@ -0,0 +1,58 @@
|
|||||||
|
# Generated by Django 5.1.2 on 2024-10-28 01:55
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("documents", "1055_alter_storagepath_path"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="customfieldinstance",
|
||||||
|
name="deleted_at",
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="customfieldinstance",
|
||||||
|
name="restored_at",
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="customfieldinstance",
|
||||||
|
name="transaction_id",
|
||||||
|
field=models.UUIDField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="note",
|
||||||
|
name="deleted_at",
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="note",
|
||||||
|
name="restored_at",
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="note",
|
||||||
|
name="transaction_id",
|
||||||
|
field=models.UUIDField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="sharelink",
|
||||||
|
name="deleted_at",
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="sharelink",
|
||||||
|
name="restored_at",
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="sharelink",
|
||||||
|
name="transaction_id",
|
||||||
|
field=models.UUIDField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
@ -710,7 +710,7 @@ class PaperlessTask(models.Model):
|
|||||||
return f"Task {self.task_id}"
|
return f"Task {self.task_id}"
|
||||||
|
|
||||||
|
|
||||||
class Note(models.Model):
|
class Note(SoftDeleteModel):
|
||||||
note = models.TextField(
|
note = models.TextField(
|
||||||
_("content"),
|
_("content"),
|
||||||
blank=True,
|
blank=True,
|
||||||
@ -750,7 +750,7 @@ class Note(models.Model):
|
|||||||
return self.note
|
return self.note
|
||||||
|
|
||||||
|
|
||||||
class ShareLink(models.Model):
|
class ShareLink(SoftDeleteModel):
|
||||||
class FileVersion(models.TextChoices):
|
class FileVersion(models.TextChoices):
|
||||||
ARCHIVE = ("archive", _("Archive"))
|
ARCHIVE = ("archive", _("Archive"))
|
||||||
ORIGINAL = ("original", _("Original"))
|
ORIGINAL = ("original", _("Original"))
|
||||||
@ -866,7 +866,7 @@ class CustomField(models.Model):
|
|||||||
return f"{self.name} : {self.data_type}"
|
return f"{self.name} : {self.data_type}"
|
||||||
|
|
||||||
|
|
||||||
class CustomFieldInstance(models.Model):
|
class CustomFieldInstance(SoftDeleteModel):
|
||||||
"""
|
"""
|
||||||
A single instance of a field, attached to a CustomField for the name and type
|
A single instance of a field, attached to a CustomField for the name and type
|
||||||
and attached to a single Document to be metadata for it
|
and attached to a single Document to be metadata for it
|
||||||
|
@ -855,6 +855,8 @@ class DocumentSerializer(
|
|||||||
super().update(instance, validated_data)
|
super().update(instance, validated_data)
|
||||||
else:
|
else:
|
||||||
super().update(instance, validated_data)
|
super().update(instance, validated_data)
|
||||||
|
# hard delete custom field instances that were soft deleted
|
||||||
|
CustomFieldInstance.deleted_objects.filter(document=instance).delete()
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -296,7 +296,7 @@ def validate_filepath_template_and_render(
|
|||||||
else:
|
else:
|
||||||
# or use the real document information
|
# or use the real document information
|
||||||
tags_list = document.tags.order_by("name").all()
|
tags_list = document.tags.order_by("name").all()
|
||||||
custom_fields = document.custom_fields.all()
|
custom_fields = CustomFieldInstance.global_objects.filter(document=document)
|
||||||
|
|
||||||
# Build the context dictionary
|
# Build the context dictionary
|
||||||
context = (
|
context = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user