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

🔥 Delete component_translations serializer fields #4974

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 0 additions & 53 deletions src/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7019,38 +7019,6 @@ components:
description: |-
* `bool` - Boolean
* `json` - JSON
ComponentTranslations:
type: object
description: |-
Nest translations for literals used in the FormIO configuration inside the serializer.

This serializer produces a similar structure as the `translations` for model fields,
except that the literals are dependent on the literals used in the components defined
in the FormIO configuration.

Literals are mapped to their translation, e.g. a configuration with a `TextField`
with default label `Text field` and `FileField` with default label `File field`
could look as follows:

ParentModelSerializer:
... other fields/serializers

ComponentTranslationsSerializer:
nl:
"Text field": "Tekstveld"
"File field": "Uploadveld"
en:
"Text field": "Text field"
"File field": "File field"
properties:
nl:
type: object
additionalProperties:
type: string
en:
type: object
additionalProperties:
type: string
ConfirmationEmailTemplate:
type: object
properties:
Expand Down Expand Up @@ -7873,10 +7841,6 @@ components:
description: Allow this definition to be re-used in multiple forms
translations:
$ref: '#/components/schemas/FormDefinitionModelTranslations'
componentTranslations:
allOf:
- $ref: '#/components/schemas/ComponentTranslations'
nullable: true
required:
- configuration
- name
Expand Down Expand Up @@ -7924,10 +7888,6 @@ components:
description: Allow this definition to be re-used in multiple forms
translations:
$ref: '#/components/schemas/FormDefinitionDetailModelTranslations'
componentTranslations:
allOf:
- $ref: '#/components/schemas/ComponentTranslations'
nullable: true
usedIn:
type: array
items:
Expand Down Expand Up @@ -8339,12 +8299,7 @@ components:
$ref: '#/components/schemas/FormStepLiterals'
translations:
$ref: '#/components/schemas/FormStepModelTranslations'
componentTranslations:
allOf:
- $ref: '#/components/schemas/ComponentTranslations'
readOnly: true
required:
- componentTranslations
- configuration
- formDefinition
- index
Expand Down Expand Up @@ -9443,10 +9398,6 @@ components:
description: Allow this definition to be re-used in multiple forms
translations:
$ref: '#/components/schemas/FormDefinitionModelTranslations'
componentTranslations:
allOf:
- $ref: '#/components/schemas/ComponentTranslations'
nullable: true
PatchedFormStep:
type: object
properties:
Expand Down Expand Up @@ -9491,10 +9442,6 @@ components:
$ref: '#/components/schemas/FormStepLiterals'
translations:
$ref: '#/components/schemas/FormStepModelTranslations'
componentTranslations:
allOf:
- $ref: '#/components/schemas/ComponentTranslations'
readOnly: true
PaymentBackendEnum:
enum:
- ogone-legacy
Expand Down
10 changes: 1 addition & 9 deletions src/openforms/forms/api/serializers/form_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

from openforms.api.serializers import PublicFieldsSerializerMixin
from openforms.formio.service import rewrite_formio_components_for_request
from openforms.translations.api.serializers import (
ComponentTranslationsSerializer,
ModelTranslationsSerializer,
)
from openforms.translations.api.serializers import ModelTranslationsSerializer

from ...models import Form, FormDefinition
from ...validators import (
Expand Down Expand Up @@ -68,9 +65,6 @@ class FormDefinitionSerializer(
PublicFieldsSerializerMixin, serializers.HyperlinkedModelSerializer
):
translations = ModelTranslationsSerializer()
component_translations = ComponentTranslationsSerializer(
required=False, allow_null=True
)
configuration = FormDefinitionConfigurationSerializer(
label=_("Form.io configuration"),
help_text=_("The form definition as Form.io JSON schema"),
Expand All @@ -93,7 +87,6 @@ class Meta:
"login_required",
"is_reusable",
"translations",
"component_translations",
)
public_fields = (
"url",
Expand All @@ -104,7 +97,6 @@ class Meta:
"configuration",
"login_required",
"is_reusable",
"component_translations",
)
extra_kwargs = {
"url": {
Expand Down
11 changes: 1 addition & 10 deletions src/openforms/forms/api/serializers/form_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
from rest_framework_nested.relations import NestedHyperlinkedRelatedField

from openforms.api.serializers import PublicFieldsSerializerMixin
from openforms.translations.api.serializers import (
ComponentTranslationsSerializer,
ModelTranslationsSerializer,
)
from openforms.translations.api.serializers import ModelTranslationsSerializer

from ...models import FormDefinition, FormStep
from ...tasks import on_formstep_save_event
Expand Down Expand Up @@ -95,10 +92,6 @@ class FormStepSerializer(
read_only=True,
)
translations = ModelTranslationsSerializer()
component_translations = ComponentTranslationsSerializer(
source="form_definition.component_translations",
read_only=True,
)

parent_lookup_kwargs = {
"form_uuid_or_slug": "form__uuid",
Expand All @@ -120,7 +113,6 @@ class Meta:
"is_reusable",
"literals",
"translations",
"component_translations",
)
public_fields = (
"uuid",
Expand All @@ -135,7 +127,6 @@ class Meta:
"login_required",
"is_reusable",
"literals",
"component_translations",
)

extra_kwargs = {
Expand Down
5 changes: 0 additions & 5 deletions src/openforms/forms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,6 @@ def import_form_data(
deserialized.validated_data["configuration"]
)

# field 'component_translations' has been deprecated and it's not part of
# the 'form_definition' model anymore. We use it only in the serializer.
if "component_translations" in deserialized.validated_data:
del deserialized.validated_data["component_translations"]

if resource == "formLogic":
clear_old_service_fetch_config(deserialized.validated_data)

Expand Down
34 changes: 0 additions & 34 deletions src/openforms/translations/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,37 +105,3 @@ def _get_field(self, language_code: str):
return build_translated_model_fields_serializer(
base, language_code, translatable_fields
)


class ComponentTranslationsSerializer(serializers.Serializer):
"""
Nest translations for literals used in the FormIO configuration inside the serializer.

This serializer produces a similar structure as the `translations` for model fields,
except that the literals are dependent on the literals used in the components defined
in the FormIO configuration.

Literals are mapped to their translation, e.g. a configuration with a `TextField`
with default label `Text field` and `FileField` with default label `File field`
could look as follows:

ParentModelSerializer:
... other fields/serializers

ComponentTranslationsSerializer:
nl:
"Text field": "Tekstveld"
"File field": "Uploadveld"
en:
"Text field": "Text field"
"File field": "File field"
"""

def get_fields(self):
fields = {
language_code: serializers.DictField(
child=serializers.CharField(), required=False
)
for language_code, label in settings.LANGUAGES
}
return fields
Loading