Skip to content

feat: implement a new initialization pipeline step and runtime patchi…#299

Merged
andrey-canon merged 2 commits intomasterfrom
teak-mig/FUTUREX-1447
Nov 13, 2025
Merged

feat: implement a new initialization pipeline step and runtime patchi…#299
andrey-canon merged 2 commits intomasterfrom
teak-mig/FUTUREX-1447

Conversation

@andrey-canon
Copy link
Collaborator

Description

This pull request introduces a new runtime patch for the openedx.core.djangoapps.user_authn.api.form_fields module.
The patch enables dynamic generation of registration field handlers (add__field) based on extende_profile_fields values, allowing tenants to define and translate fields without modifying the LMS codebase.

Issue # 1447

Testing instructions

  1. Add the following setting in your tenant config
    "EXTRA_FIELD_OPTIONS": {
        "movie": [
            "Harry Potter",
            "Karate kid"
        ],
        "sport": [
            "soccer",
            "football",
            "tennis"
        ]
    },
    "REGISTRATION_EXTRA_FIELDS": {
        "hobby": "optional",
        "movie": "optional",
        "sport": "optional"
    },
    "REGISTRATION_FIELD_ORDER": [
        "hobby",
        "sport",
        "movie"
    ],
    "extended_profile_fields": [
        "hobby",
        "sport",
        "movie"
    ],
    "extended_profile_fields_translations": {
        "ar": {
            "hobby": "\u0647\u0648\u0627\u064a\u0629",
            "movie": "\u0641\u064a\u0644\u0645",
            "sport": "\u0631\u064a\u0627\u0636\u0629"
        }
    },
    "ENABLE_DYNAMIC_REGISTRATION_FIELDS": true
  1. Go to http://local.openedx.io:8000/api/mfe_context?is_register_page=true and validate the optionalFields key

Before

image

After

image

Copy link
Collaborator

@johanseto johanseto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working in my local env

Screencast.from.04-11-25.14.54.46.webm

Only some comments.

Updates the default Open edX gender field options to include only "Male" and "Female"
for compatibility with specific business rules.

set_mako_templates:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice update of docstrings =)

if field_name in extended_profile_fields:
return _generate_handler(field_name)

raise AttributeError()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exception could send some data or something more informative.

Comment on lines +65 to +75
mock_get_request.return_value = self.mock_request

configuration_helpers.get_value.side_effect = lambda key, default=None: {
"extended_profile_fields": ["sport"],
"extended_profile_fields_translations": {
"es": {field_name: translated_label},
},
}.get(key, default)

handler = patches.form_field_getattr_patch(attribute)
handler(is_field_required=False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mock_get_request.return_value = self.mock_request
configuration_helpers.get_value.side_effect = lambda key, default=None: {
"extended_profile_fields": ["sport"],
"extended_profile_fields_translations": {
"es": {field_name: translated_label},
},
}.get(key, default)
handler = patches.form_field_getattr_patch(attribute)
handler(is_field_required=False)
mock_get_request.return_value = self.mock_request
configuration_helpers.get_value.side_effect = lambda key, default=None: {
"extended_profile_fields": ["sport"],
"extended_profile_fields_translations": {
"es": {field_name: translated_label},
},
}.get(key, default)
handler = patches.form_field_getattr_patch(attribute)
handler(is_field_required=False)

Copy link
Collaborator

@johanseto johanseto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrey-canon andrey-canon merged commit fa924d2 into master Nov 13, 2025
9 checks passed
@andrey-canon andrey-canon deleted the teak-mig/FUTUREX-1447 branch November 13, 2025 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants