Fix: Make customfieldinstance soft delete, fix filepath when deleted

This commit is contained in:
shamoon 2024-10-27 18:52:38 -07:00
parent 28fdb170bf
commit 53b63656d8
3 changed files with 30 additions and 2 deletions

View File

@ -0,0 +1,28 @@
# Generated by Django 5.1.2 on 2024-10-28 01:46
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),
),
]

View File

@ -866,7 +866,7 @@ class CustomField(models.Model):
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
and attached to a single Document to be metadata for it

View File

@ -296,7 +296,7 @@ def validate_filepath_template_and_render(
else:
# or use the real document information
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
context = (