From 26d8c2166d5fa471cd06ec2a411afd905e7558d7 Mon Sep 17 00:00:00 2001 From: Paulo Viadanna Date: Thu, 30 Mar 2023 11:12:35 -0300 Subject: [PATCH] feat: implements SHOW_REGISTRATION_LINKS feature toggle (cherry picked from commit 3025ab5fe6f6f53d6af5b36681355efafa37c74b) --- cms/envs/common.py | 3 +++ cms/templates/howitworks.html | 2 +- cms/templates/widgets/header.html | 2 +- lms/envs/common.py | 9 +++++++++ lms/static/js/student_account/views/AccessView.js | 8 ++++++-- lms/static/js/student_account/views/FormView.js | 6 ++++++ lms/static/js/student_account/views/LoginView.js | 3 +++ lms/static/js/student_account/views/RegisterView.js | 3 ++- lms/templates/header/navbar-not-authenticated.html | 2 +- lms/templates/navigation/navbar-not-authenticated.html | 2 +- lms/templates/student_account/form_field.underscore | 6 ++++-- openedx/core/djangoapps/user_authn/views/login_form.py | 1 + 12 files changed, 38 insertions(+), 9 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index a0ae0f0054..cbc100bcab 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -344,6 +344,9 @@ FEATURES = { # Allow public account creation 'ALLOW_PUBLIC_ACCOUNT_CREATION': True, + # Allow showing the registration links + 'SHOW_REGISTRATION_LINKS': True, + # Whether or not the dynamic EnrollmentTrackUserPartition should be registered. 'ENABLE_ENROLLMENT_TRACK_USER_PARTITION': True, diff --git a/cms/templates/howitworks.html b/cms/templates/howitworks.html index b04a207eba..d21dff2d66 100644 --- a/cms/templates/howitworks.html +++ b/cms/templates/howitworks.html @@ -154,7 +154,7 @@ -% if static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')): +% if static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')) and settings.FEATURES.get('SHOW_REGISTRATION_LINKS', True):
diff --git a/cms/templates/widgets/header.html b/cms/templates/widgets/header.html index 85e6495dc3..fc93aba59d 100644 --- a/cms/templates/widgets/header.html +++ b/cms/templates/widgets/header.html @@ -364,7 +364,7 @@ - % if static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')): + % if static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')) and settings.FEATURES.get('SHOW_REGISTRATION_LINKS', True): diff --git a/lms/envs/common.py b/lms/envs/common.py index a7c2603030..4f9d9d17f4 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -779,6 +779,15 @@ FEATURES = { # .. toggle_tickets: https://openedx.atlassian.net/browse/YONK-513 'ALLOW_PUBLIC_ACCOUNT_CREATION': True, + # .. toggle_name: FEATURES['SHOW_REGISTRATION_LINKS'] + # .. toggle_implementation: DjangoSetting + # .. toggle_default: True + # .. toggle_description: Allow registration links. If this is disabled, users will no longer see buttons to the + # the signup page. + # .. toggle_use_cases: open_edx + # .. toggle_creation_date: 2023-03-27 + 'SHOW_REGISTRATION_LINKS': True, + # .. toggle_name: FEATURES['ENABLE_COOKIE_CONSENT'] # .. toggle_implementation: DjangoSetting # .. toggle_default: False diff --git a/lms/static/js/student_account/views/AccessView.js b/lms/static/js/student_account/views/AccessView.js index 0ecf40e464..b5ad270514 100644 --- a/lms/static/js/student_account/views/AccessView.js +++ b/lms/static/js/student_account/views/AccessView.js @@ -76,7 +76,8 @@ this.platformName = options.platform_name; this.supportURL = options.support_link; this.passwordResetSupportUrl = options.password_reset_support_link; - this.createAccountOption = options.account_creation_allowed; + this.createAccountOption = options.account_creation_allowed && options.register_links_allowed; + this.showRegisterLinks = options.register_links_allowed; this.hideAuthWarnings = options.hide_auth_warnings || false; this.pipelineUserDetails = options.third_party_auth.pipeline_user_details; this.enterpriseName = options.enterprise_name || ''; @@ -162,6 +163,7 @@ supportURL: this.supportURL, passwordResetSupportUrl: this.passwordResetSupportUrl, createAccountOption: this.createAccountOption, + showRegisterLinks: this.showRegisterLinks, hideAuthWarnings: this.hideAuthWarnings, pipelineUserDetails: this.pipelineUserDetails, enterpriseName: this.enterpriseName, @@ -187,7 +189,8 @@ this.subview.passwordHelp = new PasswordResetView({ fields: data.fields, - model: this.resetModel + model: this.resetModel, + showRegisterLinks: this.showRegisterLinks }); // Listen for 'password-email-sent' event to toggle sub-views @@ -212,6 +215,7 @@ hideAuthWarnings: this.hideAuthWarnings, is_require_third_party_auth_enabled: this.is_require_third_party_auth_enabled, enableCoppaCompliance: this.enable_coppa_compliance, + showRegisterLinks: this.showRegisterLinks }); // Listen for 'auth-complete' event so we can enroll/redirect the user appropriately. diff --git a/lms/static/js/student_account/views/FormView.js b/lms/static/js/student_account/views/FormView.js index c015a61842..321bb7b942 100644 --- a/lms/static/js/student_account/views/FormView.js +++ b/lms/static/js/student_account/views/FormView.js @@ -33,9 +33,14 @@ optionalStr: gettext('(optional)'), submitButton: '', isEnterpriseEnable: false, + showRegisterLinks: true, initialize: function(data) { this.model = data.model; + this.showRegisterLinks = ( + typeof data.showRegisterLinks !== 'undefined' + ) ? data.showRegisterLinks : this.showRegisterLinks; + this.preRender(data); this.tpl = $(this.tpl).html(); @@ -98,6 +103,7 @@ supplementalText: data[i].supplementalText || '', supplementalLink: data[i].supplementalLink || '', loginIssueSupportLink: data[i].loginIssueSupportLink || '', + showRegisterLinks: this.showRegisterLinks, isEnterpriseEnable: this.isEnterpriseEnable }))); } diff --git a/lms/static/js/student_account/views/LoginView.js b/lms/static/js/student_account/views/LoginView.js index 818c63144a..5832f2c088 100644 --- a/lms/static/js/student_account/views/LoginView.js +++ b/lms/static/js/student_account/views/LoginView.js @@ -53,6 +53,9 @@ this.supportURL = data.supportURL; this.passwordResetSupportUrl = data.passwordResetSupportUrl; this.createAccountOption = data.createAccountOption; + this.showRegisterLinks = ( + typeof data.showRegisterLinks !== 'undefined' + ) ? data.showRegisterLinks : this.showRegisterLinks; this.accountActivationMessages = data.accountActivationMessages; this.accountRecoveryMessages = data.accountRecoveryMessages; this.hideAuthWarnings = data.hideAuthWarnings; diff --git a/lms/static/js/student_account/views/RegisterView.js b/lms/static/js/student_account/views/RegisterView.js index 613dc7afed..42ab7c8857 100644 --- a/lms/static/js/student_account/views/RegisterView.js +++ b/lms/static/js/student_account/views/RegisterView.js @@ -87,7 +87,8 @@ requiredStr: this.requiredStr, optionalStr: fields[i].name === 'marketing_emails_opt_in' ? '' : this.optionalStr, supplementalText: fields[i].supplementalText || '', - supplementalLink: fields[i].supplementalLink || '' + supplementalLink: fields[i].supplementalLink || '', + showRegisterLinks: this.showRegisterLinks }))); } html.push('
'); diff --git a/lms/templates/header/navbar-not-authenticated.html b/lms/templates/header/navbar-not-authenticated.html index c1e7200ed5..61448b73bd 100644 --- a/lms/templates/header/navbar-not-authenticated.html +++ b/lms/templates/header/navbar-not-authenticated.html @@ -18,7 +18,7 @@ from openedx.core.djangoapps.user_authn.toggles import should_redirect_to_authn_ courses_are_browsable = settings.FEATURES.get('COURSES_ARE_BROWSABLE') allows_login = not settings.FEATURES['DISABLE_LOGIN_BUTTON'] and not combined_login_and_register can_discover_courses = settings.FEATURES.get('ENABLE_COURSE_DISCOVERY') - allow_public_account_creation = static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')) + allow_public_account_creation = static.get_value('ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION')) and settings.FEATURES.get('SHOW_REGISTRATION_LINKS', True) should_redirect_to_authn_mfe = should_redirect_to_authn_microfrontend() %>