mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-16 21:55:37 -05:00
Enhancement: long text custom field (#10846)
--------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
@@ -230,6 +230,7 @@ class CustomFieldsFilter(Filter):
|
||||
| qs.filter(custom_fields__value_monetary__icontains=value)
|
||||
| qs.filter(custom_fields__value_document_ids__icontains=value)
|
||||
| qs.filter(custom_fields__value_select__in=option_ids)
|
||||
| qs.filter(custom_fields__value_long_text__icontains=value)
|
||||
)
|
||||
else:
|
||||
return qs
|
||||
@@ -314,6 +315,7 @@ class CustomFieldQueryParser:
|
||||
CustomField.FieldDataType.MONETARY: ("basic", "string", "arithmetic"),
|
||||
CustomField.FieldDataType.DOCUMENTLINK: ("basic", "containment"),
|
||||
CustomField.FieldDataType.SELECT: ("basic",),
|
||||
CustomField.FieldDataType.LONG_TEXT: ("basic", "string"),
|
||||
}
|
||||
|
||||
DATE_COMPONENTS = [
|
||||
@@ -845,7 +847,10 @@ class DocumentsOrderingFilter(OrderingFilter):
|
||||
|
||||
annotation = None
|
||||
match field.data_type:
|
||||
case CustomField.FieldDataType.STRING:
|
||||
case (
|
||||
CustomField.FieldDataType.STRING
|
||||
| CustomField.FieldDataType.LONG_TEXT
|
||||
):
|
||||
annotation = Subquery(
|
||||
CustomFieldInstance.objects.filter(
|
||||
document_id=OuterRef("id"),
|
||||
|
@@ -0,0 +1,39 @@
|
||||
# Generated by Django 5.2.6 on 2025-09-13 17:11
|
||||
|
||||
from django.db import migrations
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("documents", "1069_workflowtrigger_filter_has_storage_path_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="customfieldinstance",
|
||||
name="value_long_text",
|
||||
field=models.TextField(null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="customfield",
|
||||
name="data_type",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("string", "String"),
|
||||
("url", "URL"),
|
||||
("date", "Date"),
|
||||
("boolean", "Boolean"),
|
||||
("integer", "Integer"),
|
||||
("float", "Float"),
|
||||
("monetary", "Monetary"),
|
||||
("documentlink", "Document Link"),
|
||||
("select", "Select"),
|
||||
("longtext", "Long Text"),
|
||||
],
|
||||
editable=False,
|
||||
max_length=50,
|
||||
verbose_name="data type",
|
||||
),
|
||||
),
|
||||
]
|
@@ -759,6 +759,7 @@ class CustomField(models.Model):
|
||||
MONETARY = ("monetary", _("Monetary"))
|
||||
DOCUMENTLINK = ("documentlink", _("Document Link"))
|
||||
SELECT = ("select", _("Select"))
|
||||
LONG_TEXT = ("longtext", _("Long Text"))
|
||||
|
||||
created = models.DateTimeField(
|
||||
_("created"),
|
||||
@@ -816,6 +817,7 @@ class CustomFieldInstance(SoftDeleteModel):
|
||||
CustomField.FieldDataType.MONETARY: "value_monetary",
|
||||
CustomField.FieldDataType.DOCUMENTLINK: "value_document_ids",
|
||||
CustomField.FieldDataType.SELECT: "value_select",
|
||||
CustomField.FieldDataType.LONG_TEXT: "value_long_text",
|
||||
}
|
||||
|
||||
created = models.DateTimeField(
|
||||
@@ -883,6 +885,8 @@ class CustomFieldInstance(SoftDeleteModel):
|
||||
|
||||
value_select = models.CharField(null=True, max_length=16)
|
||||
|
||||
value_long_text = models.TextField(null=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ("created",)
|
||||
verbose_name = _("custom field instance")
|
||||
|
@@ -202,6 +202,7 @@ def get_custom_fields_context(
|
||||
CustomField.FieldDataType.MONETARY,
|
||||
CustomField.FieldDataType.STRING,
|
||||
CustomField.FieldDataType.URL,
|
||||
CustomField.FieldDataType.LONG_TEXT,
|
||||
}:
|
||||
value = pathvalidate.sanitize_filename(
|
||||
field_instance.value,
|
||||
|
Reference in New Issue
Block a user