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

feat: implements SHOW_REGISTRATION_LINKS feature toggle #528

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,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 @@ -153,7 +153,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 @@ -264,7 +264,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=${current_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 @@ -765,6 +765,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
8 changes: 6 additions & 2 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,6 +162,7 @@
supportURL: this.supportURL,
passwordResetSupportUrl: this.passwordResetSupportUrl,
createAccountOption: this.createAccountOption,
showRegisterLinks: this.showRegisterLinks,
hideAuthWarnings: this.hideAuthWarnings,
pipelineUserDetails: this.pipelineUserDetails,
enterpriseName: this.enterpriseName,
Expand All @@ -186,7 +188,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
Expand All @@ -211,6 +214,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.
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
3 changes: 2 additions & 1 deletion lms/static/js/student_account/views/RegisterView.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +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>');
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 @@ -145,10 +145,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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<%
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)
%>
<nav class="nav-links" aria-label='${_("Sign in")}'>
<div class="secondary">
Expand Down