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

PADV-1556 Create custom form for registration extra fields. #129

Merged
merged 1 commit into from
Sep 18, 2024
Merged
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
13 changes: 9 additions & 4 deletions openedx/core/djangoapps/user_authn/views/registration_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,18 @@ def cleaned_extended_profile(self):

def get_registration_extension_form(*args, **kwargs):
"""
Convenience function for getting the custom form set in settings.REGISTRATION_EXTENSION_FORM.
Convenience function for getting the custom form set in site configurations or plataform settings
REGISTRATION_EXTENSION_FORM.

An example form app for this can be found at http://github.com/open-craft/custom-form-app
Documentation on how to enable this feature can be found on
https://github.com/Pearson-Advance/pearson-core/blob/master/docs/pearson_core_features.md#amazon-custom-registration-form
"""
if not getattr(settings, 'REGISTRATION_EXTENSION_FORM', None):
# No Default valued is passed since we prioritize site configurations over site settings.
registration_extra_form = configuration_helpers.get_value('REGISTRATION_EXTENSION_FORM',

Choose a reason for hiding this comment

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

You should keep checking the existence of the default value, as it's now, it will throw an error if the setting is not present. Also if the setting is present but is None, it will fail on line 310. @Nekenhei

Copy link
Author

Choose a reason for hiding this comment

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

Hi @Squirrel18 you're right, I've removed by error an if statement that handles the situation when none of the sources has the setting set.

In the original code, the default value was none, so I changed to firstly check for site conf, then plataform settings and if none of them are presented, return None as it's working on master.

settings.REGISTRATION_EXTENSION_FORM)
if not registration_extra_form:
return None
module, klass = settings.REGISTRATION_EXTENSION_FORM.rsplit('.', 1)
module, klass = registration_extra_form.rsplit('.', 1)
module = import_module(module)
return getattr(module, klass)(*args, **kwargs)

Expand Down
Loading