Skip to content

Commit

Permalink
feat: implements SHOW_REGISTRATION_LINKS feature toggle (#528)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3025ab5)
  • Loading branch information
viadanna authored and xitij2000 committed Jun 26, 2023
1 parent 17dd0ec commit 64d2883
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 13 deletions.
3 changes: 3 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@
# 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,

Expand Down
2 changes: 1 addition & 1 deletion cms/templates/howitworks.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ <h4 class="title">${_("Work in Teams")}</h4>
</section>
</div>

% 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):
<div class="wrapper-content-cta wrapper">
<section class="content content-cta">
<header>
Expand Down
2 changes: 1 addition & 1 deletion cms/templates/widgets/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ <h2 class="sr-only">${_("Account Navigation")}</h2>
<li class="nav-item nav-not-signedin-help">
<a href="${get_online_help_info(online_help_token)['doc_url']}" title="${_('Contextual Online Help')}" rel="noopener" target="_blank">${_("Help")}</a>
</li>
% 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):
<li class="nav-item nav-not-signedin-signup">
<a class="action action-signup" href="${settings.FRONTEND_REGISTER_URL}?next=${quote_plus(request.build_absolute_uri(settings.LOGIN_URL))}">${_("Sign Up")}</a>
</li>
Expand Down
9 changes: 9 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,15 @@
# .. 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
Expand Down
13 changes: 8 additions & 5 deletions lms/static/js/student_account/views/AccessView.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,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 || '';
Expand Down Expand Up @@ -161,7 +162,7 @@
supportURL: this.supportURL,
passwordResetSupportUrl: this.passwordResetSupportUrl,
createAccountOption: this.createAccountOption,
hideAuthWarnings: this.hideAuthWarnings,
showRegisterLinks: this.showRegisterLinks,hideAuthWarnings: this.hideAuthWarnings,
pipelineUserDetails: this.pipelineUserDetails,
enterpriseName: this.enterpriseName,
enterpriseSlugLoginURL: this.enterpriseSlugLoginURL,
Expand All @@ -186,8 +187,9 @@

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
this.listenTo(this.subview.passwordHelp, 'password-email-sent', this.passwordEmailSent);
Expand All @@ -211,7 +213,8 @@
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.
this.listenTo(this.subview.register, 'auth-complete', this.authComplete);
Expand Down
2 changes: 2 additions & 0 deletions lms/static/js/student_account/views/FormView.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

initialize: function(data) {
this.model = data.model;
this.showRegisterLinks = data.showRegisterLinks;
this.preRender(data);

this.tpl = $(this.tpl).html();
Expand Down Expand Up @@ -97,6 +98,7 @@
supplementalText: data[i].supplementalText || '',
supplementalLink: data[i].supplementalLink || '',
loginIssueSupportLink: data[i].loginIssueSupportLink || '',
showRegisterLinks: this.showRegisterLinks,
isEnterpriseEnable: this.isEnterpriseEnable
})));
}
Expand Down
1 change: 1 addition & 0 deletions lms/static/js/student_account/views/LoginView.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
this.supportURL = data.supportURL;
this.passwordResetSupportUrl = data.passwordResetSupportUrl;
this.createAccountOption = data.createAccountOption;
this.showRegisterLinks = data.showRegisterLinks;
this.accountActivationMessages = data.accountActivationMessages;
this.accountRecoveryMessages = data.accountRecoveryMessages;
this.hideAuthWarnings = data.hideAuthWarnings;
Expand Down
4 changes: 2 additions & 2 deletions lms/static/js/student_account/views/RegisterView.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,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('</div>');
return html;
Expand Down
2 changes: 1 addition & 1 deletion lms/templates/header/navbar-not-authenticated.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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()
%>
<nav class="nav-links" aria-label=${_("Supplemental Links")}>
Expand Down
2 changes: 1 addition & 1 deletion lms/templates/navigation/navbar-not-authenticated.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<a class="btn" href="/courses">${_("Explore Courses")}</a>
</li>
%endif
% 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):
<li class="item nav-global-04">
<a class="btn btn-neutral btn-register" href="/register${login_query()}">${_("Register")}</a>
</li>
Expand Down
6 changes: 4 additions & 2 deletions lms/templates/student_account/form_field.underscore
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@
<button type="button" class="enterprise-login field-link"><%- gettext("Sign in with your company or school") %></button>
<% } %>
<% } %>
<% if( form === 'password-reset' && name === 'email' ) { %>
<% if( (showRegisterLinks || loginIssueSupportLink) && form === 'password-reset' && name === 'email' ) { %>
<button type="button" class="reset-help field-link" ><i class="fa fa-caret-right" /><%- gettext("Need other help signing in?") %></button>
<div id="reset-help" style="display:none">
<button type="button" class="field-link form-toggle" data-type="register"><%- gettext("Create an account") %></button>
<% if ( showRegisterLinks ) { %>
<button type="button" class="field-link form-toggle" data-type="register"><%- gettext("Create an account") %></button>
<% } %>
<% if ( loginIssueSupportLink ) { %>
<span><a class="field-link" href="<%- loginIssueSupportLink %>"><%- gettext("Other sign-in issues") %></a></span>
<% } %>
Expand Down
1 change: 1 addition & 0 deletions openedx/core/djangoapps/user_authn/views/login_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def login_and_registration_form(request, initial_mode="login"):
'password_reset_form_desc': json.loads(form_descriptions['password_reset']),
'account_creation_allowed': configuration_helpers.get_value(
'ALLOW_PUBLIC_ACCOUNT_CREATION', settings.FEATURES.get('ALLOW_PUBLIC_ACCOUNT_CREATION', True)),
'register_links_allowed': settings.FEATURES.get('SHOW_REGISTRATION_LINKS', True),
'is_account_recovery_feature_enabled': is_secondary_email_feature_enabled(),
'enterprise_slug_login_url': get_enterprise_slug_login_url(),
'is_enterprise_enable': enterprise_enabled(),
Expand Down

0 comments on commit 64d2883

Please sign in to comment.