Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZGW UX improvements: select document type #4817

Merged
merged 18 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a3f847f
:wastebasket: [#4606] Deprecate ZGW url-based document type configura…
sergei-maertens Nov 11, 2024
5297cfd
:sparkles: [#4606] Implement frontend to select document type from ca…
sergei-maertens Nov 11, 2024
5bbfb76
:sparkles: [#4606] Add ZGW config option for document type
sergei-maertens Nov 11, 2024
c3937c1
:white_check_mark: [#4606] Add test for document type validation
sergei-maertens Nov 11, 2024
6c2f1a1
:safety_vest: [#4606] Validate document type reference
sergei-maertens Nov 11, 2024
1cdad20
:boom: [#4606] Rename serializer and fields to English
sergei-maertens Nov 12, 2024
32c41e6
:boom: [#4606] Normalize API endpoints
sergei-maertens Nov 12, 2024
e04c3b9
:sparkles: [#4606] Implement filtering document types down to particu…
sergei-maertens Nov 12, 2024
62cc377
:boom: More NL -> EN in API endpoints
sergei-maertens Nov 12, 2024
aa61ec0
:green_heart: [#4606] Update broken tests
sergei-maertens Nov 12, 2024
e836772
:white_check_mark: [#4606] Add more test cases for document type vali…
sergei-maertens Nov 14, 2024
34c2fc8
:label: [#4606] Type-check zgw tests modules
sergei-maertens Nov 14, 2024
bc17639
:recycle: [#4606] Refactor case type resolution into private helper
sergei-maertens Nov 14, 2024
1202969
:sparkles: [#4606] Implement dynamically resolving the document type
sergei-maertens Nov 14, 2024
b66b244
:label: [#4606] Fix type checker errors after rebasing on product fea…
sergei-maertens Nov 20, 2024
eaff396
:art: Cleanup leftovers from product feature
sergei-maertens Nov 20, 2024
1829cc1
:ok_hand: [#4606] PR feedback - update language
sergei-maertens Nov 25, 2024
fe771da
:recycle: [#4606] Rename URL name to get list of document types
sergei-maertens Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyright.pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ include = [
exclude = [
"**/__pycache__",
"src/openforms/formio/formatters/tests/",
"src/openforms/registrations/contrib/zgw_apis/tests/",
"src/openforms/registrations/contrib/zgw_apis/tests/test_backend_partial_failure.py",
"src/openforms/registrations/contrib/zgw_apis/tests/test_utils.py",
]
ignore = []

Expand Down
91 changes: 54 additions & 37 deletions src/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3491,9 +3491,9 @@ paths:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
/api/v2/objects-api/informatieobjecttypen:
/api/v2/objects-api/document-types:
get:
operationId: objects_api_informatieobjecttypen_list
operationId: objects_api_document_types_list
description: |-
List the available InformatieObjectTypen.

Expand All @@ -3504,13 +3504,23 @@ paths:
API group
parameters:
- in: query
name: catalogus_url
name: case_type_identification
schema:
type: string
default: ''
minLength: 1
description: Filter document types for a given case type. The identification
is unique within the catalogue for a case type. Note that multiple versions
of the same case type with the same identification exist. The filter returns
a document type if it occurs within any version of the specified case type.
- in: query
name: catalogue_url
schema:
type: string
format: uri
default: ''
minLength: 1
description: Filter informatieobjecttypen against this catalogus URL.
description: Filter document types against this catalogue URL.
- in: query
name: objects_api_group
schema:
Expand All @@ -3529,7 +3539,7 @@ paths:
schema:
type: array
items:
$ref: '#/components/schemas/InformatieObjectType'
$ref: '#/components/schemas/DocumentType'
description: ''
headers:
X-Session-Expires-In:
Expand Down Expand Up @@ -4186,26 +4196,35 @@ paths:
$ref: '#/components/headers/X-Is-Form-Designer'
Content-Language:
$ref: '#/components/headers/Content-Language'
/api/v2/registration/plugins/zgw-api/informatieobjecttypen:
/api/v2/registration/plugins/zgw-api/document-types:
get:
operationId: registration_plugins_zgw_api_informatieobjecttypen_list
operationId: registration_plugins_zgw_api_document_types_list
description: |-
List the available InformatieObjectTypen.

Each InformatieObjectType is uniquely identified by its 'omschrijving', 'catalogus',
and beginning and end date. If multiple same InformatieObjectTypen exist for different dates,
only one entry is returned.
summary: List the available InformatieObjectTypen from the provided ZGW API
group
summary: List the available document types from the provided ZGW API group
parameters:
- in: query
name: catalogus_url
name: case_type_identification
schema:
type: string
default: ''
minLength: 1
description: Filter document types for a given case type. The identification
is unique within the catalogue for a case type. Note that multiple versions
of the same case type with the same identification exist. The filter returns
a document type if it occurs within any version of the specified case type.
- in: query
name: catalogue_url
schema:
type: string
format: uri
default: ''
minLength: 1
description: Filter informatieobjecttypen against this catalogus URL.
description: Filter document types against this catalogue URL.
- in: query
name: zgw_api_group
schema:
Expand All @@ -4224,7 +4243,7 @@ paths:
schema:
type: array
items:
$ref: '#/components/schemas/InformatieObjectType'
$ref: '#/components/schemas/DocumentType'
description: ''
headers:
X-Session-Expires-In:
Expand Down Expand Up @@ -7564,6 +7583,29 @@ components:
- form
type: string
description: '* `form` - form'
DocumentType:
type: object
properties:
description:
type: string
description: The description uniquely identifies a document type within
a catalogue. Multiple versions of the same document type may exist, these
have non-overlapping valid from/valid until dates.
isPublished:
type: boolean
description: Unpublished document types may be returned when the feature
flag 'ZGW_APIS_INCLUDE_DRAFTS' is enabled.
url:
type: string
format: uri
catalogueLabel:
type: string
description: A representation of the catalogue containing the document type.
required:
- catalogueLabel
- description
- isPublished
- url
EmailVerification:
type: object
properties:
Expand Down Expand Up @@ -8732,31 +8774,6 @@ components:
description: |-
* `delete_permanently` - Submissions will be deleted
* `make_anonymous` - Sensitive data within the submissions will be deleted
InformatieObjectType:
type: object
properties:
url:
type: string
format: uri
omschrijving:
type: string
title: description
description: The description uniquely identifies a document type within
a catalogue. Multiple versions of the same document type may exist, these
have non-overlapping valid from/valid until dates.
catalogusLabel:
type: string
title: catalogue label
description: A representation of the catalogue containing the document type.
isPublished:
type: boolean
description: Unpublished document types may be returned when the feature
flag 'ZGW_APIS_INCLUDE_DRAFTS' is enabled.
required:
- catalogusLabel
- isPublished
- omschrijving
- url
Language:
type: object
properties:
Expand Down
4 changes: 1 addition & 3 deletions src/openforms/contrib/objects_api/api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,5 @@ class APIGroupQueryParamsSerializer(
pass


class ListInformatieObjectTypenQueryParamsSerializer(
ObjectsAPIGroupMixin, DocumentTypesFilter
):
class ListDocumentTypesQueryParamsSerializer(ObjectsAPIGroupMixin, DocumentTypesFilter):
pass
8 changes: 4 additions & 4 deletions src/openforms/contrib/objects_api/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .views import (
CatalogueListView,
InformatieObjectTypenListView,
DocumentTypesListView,
ObjecttypesListView,
ObjecttypeVersionsListView,
)
Expand All @@ -26,8 +26,8 @@
name="catalogue-list",
),
path(
"informatieobjecttypen",
InformatieObjectTypenListView.as_view(),
name="iotypen-list",
"document-types",
DocumentTypesListView.as_view(),
name="document-type-list",
),
]
10 changes: 5 additions & 5 deletions src/openforms/contrib/objects_api/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from openforms.api.views import ListMixin
from openforms.contrib.zgw.api.views import (
BaseCatalogueListView,
BaseInformatieObjectTypenListView,
BaseDocumentTypesListView,
)

from ..clients import get_objecttypes_client
from .filters import (
APIGroupQueryParamsSerializer,
ListInformatieObjectTypenQueryParamsSerializer,
ListDocumentTypesQueryParamsSerializer,
)
from .serializers import (
ObjectsAPIGroupInputSerializer,
Expand Down Expand Up @@ -103,8 +103,8 @@ class CatalogueListView(BaseCatalogueListView):
"List the available InformatieObjectTypen from the provided Objects API group"
),
tags=["contrib"],
parameters=[ListInformatieObjectTypenQueryParamsSerializer],
parameters=[ListDocumentTypesQueryParamsSerializer],
),
)
class InformatieObjectTypenListView(BaseInformatieObjectTypenListView):
filter_serializer_class = ListInformatieObjectTypenQueryParamsSerializer
class DocumentTypesListView(BaseDocumentTypesListView):
filter_serializer_class = ListDocumentTypesQueryParamsSerializer
29 changes: 26 additions & 3 deletions src/openforms/contrib/zgw/api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,35 @@ def get_ztc_client(self) -> CatalogiClient:


class DocumentTypesFilter(serializers.Serializer):
catalogus_url = serializers.URLField(
label=_("catalogus URL"),
help_text=_("Filter informatieobjecttypen against this catalogus URL."),
catalogue_url = serializers.URLField(
label=_("catalogue URL"),
help_text=_("Filter document types against this catalogue URL."),
required=False,
default="",
)
case_type_identification = serializers.CharField(
required=False,
label=_("case type identification"),
help_text=_(
"Filter document types for a given case type. The identification is unique "
"within the catalogue for a case type. Note that multiple versions of the "
"same case type with the same identification exist. The filter returns a "
"document type if it occurs within any version of the specified case type."
),
default="",
)

def validate(self, attrs):
if attrs["case_type_identification"] and not attrs["catalogue_url"]:
raise serializers.ValidationError(
{
"catalogue_url": _(
"A catalogue URL is required when filtering for a case type."
),
},
code="required",
)
return attrs

def get_ztc_client(self) -> CatalogiClient:
raise NotImplementedError()
39 changes: 20 additions & 19 deletions src/openforms/contrib/zgw/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,37 +56,38 @@ class CaseTypeSerializer(serializers.Serializer):
)


class CaseTypeProductSerializer(serializers.Serializer):
url = serializers.CharField(
label=_("url"),
help_text=_("The url of a product bound to a case type. "),
)
class DocumentTypeSerializer(serializers.Serializer):
description = serializers.CharField(
label=_("description"),
help_text=_("The description of a product bound to a case type. "),
required=False,
)


# TODO: OF 3.0 -> use English instead of Dutch.
class InformatieObjectTypeSerializer(serializers.Serializer):
url = serializers.URLField(label=_("url"))
omschrijving = serializers.CharField(
label=_("description"),
help_text=_(
"The description uniquely identifies a document type within a catalogue. "
"Multiple versions of the same document type may exist, these have "
"non-overlapping valid from/valid until dates."
),
)
catalogus_label = serializers.CharField(
label=_("catalogue label"),
help_text=_("A representation of the catalogue containing the document type."),
)
is_published = serializers.BooleanField(
label=_("Is published"),
help_text=_(
"Unpublished document types may be returned when the feature flag "
"'ZGW_APIS_INCLUDE_DRAFTS' is enabled."
),
)
# DeprecationWarning - only relevant for Formio registration attributes
url = serializers.URLField(label=_("url"))
# DeprecationWarning - only relevant for Formio registration attributes
catalogue_label = serializers.CharField(
label=_("catalogue label"),
help_text=_("A representation of the catalogue containing the document type."),
)


class CaseTypeProductSerializer(serializers.Serializer):
url = serializers.CharField(
label=_("url"),
help_text=_("The url of a product bound to a case type. "),
)
description = serializers.CharField(
label=_("description"),
help_text=_("The description of a product bound to a case type. "),
required=False,
)
Loading
Loading