-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚚 [#4606] Move CatalogueSerializer to shared library code
Objects API and ZGW APIs registration backends both use the same option structure for the catalogue, so we can re-use the serializer to have a single source of truth.
- Loading branch information
1 parent
401b543
commit 2750190
Showing
2 changed files
with
46 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from rest_framework import serializers | ||
|
||
from openforms.api.validators import AllOrNoneTruthyFieldsValidator | ||
from openforms.utils.validators import RSINValidator, validate_uppercase | ||
|
||
|
||
class CatalogueSerializer(serializers.Serializer): | ||
""" | ||
Specify which catalogue to use to look up case/document types. | ||
Certain configuration models also define default fields like ``catalogue_domain`` | ||
and ``catalogue_rsin`` to fall back on, such as: | ||
- :class:`openforms.registrations.contrib.objects_api.models.ObjectsAPIGroupConfig` | ||
- :class:`openforms.registrations.contrib.zgw_apis.models.ZGWApiGroupConfig` | ||
""" | ||
|
||
domain = serializers.CharField( | ||
label=_("domain"), | ||
required=False, | ||
max_length=5, | ||
help_text=_( | ||
"The 'domein' attribute for the Catalogus resource in the Catalogi API." | ||
), | ||
default="", | ||
validators=[validate_uppercase], | ||
) | ||
rsin = serializers.CharField( | ||
label=_("RSIN"), | ||
required=False, | ||
max_length=9, | ||
validators=[RSINValidator()], | ||
help_text=_( | ||
"The 'rsin' attribute for the Catalogus resource in the Catalogi API." | ||
), | ||
default="", | ||
) | ||
|
||
class Meta: | ||
validators = [ | ||
AllOrNoneTruthyFieldsValidator("domain", "rsin"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters