mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-20 04:26:53 +00:00
Fix: reject a custom field on zones with a built-in target
Title, ASN and created zones stored a custom field that was then ignored.
This commit is contained in:
1 parent
884fbf7fb2
commit
6eb0e4e6b3
2 files changed
+70
No files matched your search
@@ -3795,6 +3795,16 @@ class OcrTemplateZoneSerializer(serializers.ModelSerializer):
|
||||
raise serializers.ValidationError(
|
||||
{name: field.error_messages["required"]},
|
||||
)
|
||||
# A custom field target may be left unassigned, as the editor creates new
|
||||
# zones; built-in targets never use a custom field.
|
||||
if (
|
||||
data.get("target", OcrTemplateZone.TargetType.CUSTOM_FIELD)
|
||||
!= OcrTemplateZone.TargetType.CUSTOM_FIELD
|
||||
and data.get("custom_field") is not None
|
||||
):
|
||||
raise serializers.ValidationError(
|
||||
{"custom_field": "Only zones targeting a custom field can set one."},
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user