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:
stumpylog committed 2026-11-19 09:02:40 -08:00
1 parent 884fbf7fb2
commit 6eb0e4e6b3
2 files changed
+70

No files matched your search

+10
View File
@@ -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