From 78f1f1916c00eb884d891d25933706dce40b3691 Mon Sep 17 00:00:00 2001 From: adeelehsan Date: Tue, 18 May 2021 10:22:03 +0500 Subject: [PATCH] Account activation popup added VAN-434 --- cms/envs/common.py | 4 ++ cms/envs/production.py | 3 ++ common/djangoapps/student/views/dashboard.py | 13 ++++- lms/envs/common.py | 10 ++++ lms/envs/production.py | 3 ++ lms/static/js/dashboard/legacy.js | 44 +++++++++++++++ lms/static/sass/multicourse/_dashboard.scss | 53 +++++++++++++++++++ lms/templates/dashboard.html | 33 +++++++++++- lms/templates/main.html | 1 + .../user_authn/api/tests/test_views.py | 32 +++++++++++ .../core/djangoapps/user_authn/api/urls.py | 7 ++- .../core/djangoapps/user_authn/api/views.py | 29 ++++++++++ .../djangoapps/user_authn/views/register.py | 8 +++ 13 files changed, 237 insertions(+), 3 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 92a6de11bc..06421b2325 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2416,3 +2416,7 @@ DEFAULT_EMAIL_LOGO_URL = 'https://edx-cdn.org/v3/default/logo.png' ############## Settings for course import olx validation ############################ COURSE_OLX_VALIDATION_STAGE = 1 COURSE_OLX_VALIDATION_IGNORE_LIST = None + +################# show account activate cta after register ######################## +SHOW_ACTIVATE_CTA_POPUP_COOKIE_NAME = 'show-account-activation-popup' +SHOW_ACCOUNT_ACTIVATION_CTA = False diff --git a/cms/envs/production.py b/cms/envs/production.py index 679cc19295..1ce1a223ae 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -608,3 +608,6 @@ COURSE_OLX_VALIDATION_IGNORE_LIST = ENV_TOKENS.get( 'COURSE_OLX_VALIDATION_IGNORE_LIST', COURSE_OLX_VALIDATION_IGNORE_LIST ) + +################# show account activate cta after register ######################## +SHOW_ACCOUNT_ACTIVATION_CTA = ENV_TOKENS.get('SHOW_ACCOUNT_ACTIVATION_CTA', SHOW_ACCOUNT_ACTIVATION_CTA) diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index 0eead5ab38..912063176c 100644 --- a/common/djangoapps/student/views/dashboard.py +++ b/common/djangoapps/student/views/dashboard.py @@ -741,6 +741,8 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem enr for enr in course_enrollments if entitlement.enrollment_course_run.course_id != enr.course_id ] + show_account_activation_popup = request.COOKIES.get(settings.SHOW_ACTIVATE_CTA_POPUP_COOKIE_NAME, None) + context = { 'urls': urls, 'programs_data': programs_data, @@ -771,6 +773,7 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem 'verification_errors': verification_errors, 'denied_banner': denied_banner, 'billing_email': settings.PAYMENT_SUPPORT_EMAIL, + 'show_account_activation_popup': show_account_activation_popup, 'user': user, 'logout_url': reverse('logout'), 'platform_name': platform_name, @@ -826,4 +829,12 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem 'resume_button_urls': resume_button_urls }) - return render_to_response('dashboard.html', context) + response = render_to_response('dashboard.html', context) + if show_account_activation_popup: + response.delete_cookie( + settings.SHOW_ACTIVATE_CTA_POPUP_COOKIE_NAME, + domain=settings.SESSION_COOKIE_DOMAIN, + path='/', + ) + + return response diff --git a/lms/envs/common.py b/lms/envs/common.py index e21b9e87d8..175d688386 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -4672,3 +4672,13 @@ DEFAULT_EMAIL_LOGO_URL = 'https://edx-cdn.org/v3/default/logo.png' ################# Settings for olx validation. ################# COURSE_OLX_VALIDATION_STAGE = 1 COURSE_OLX_VALIDATION_IGNORE_LIST = None + +################# show account activate cta after register ######################## +SHOW_ACTIVATE_CTA_POPUP_COOKIE_NAME = 'show-account-activation-popup' +# .. toggle_name: SOME_FEATURE_NAME +# .. toggle_implementation: DjangoSetting +# .. toggle_default: False +# .. toggle_description: Flag would be used to show account activation popup after the registration +# .. toggle_use_cases: open_edx +# .. toggle_tickets: https://github.com/edx/edx-platform/pull/27661 +SHOW_ACCOUNT_ACTIVATION_CTA = False diff --git a/lms/envs/production.py b/lms/envs/production.py index 449c04cca9..6ad046fcab 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -1058,3 +1058,6 @@ COURSE_OLX_VALIDATION_IGNORE_LIST = ENV_TOKENS.get( 'COURSE_OLX_VALIDATION_IGNORE_LIST', COURSE_OLX_VALIDATION_IGNORE_LIST ) + +################# show account activate cta after register ######################## +SHOW_ACCOUNT_ACTIVATION_CTA = ENV_TOKENS.get('SHOW_ACCOUNT_ACTIVATION_CTA', SHOW_ACCOUNT_ACTIVATION_CTA) diff --git a/lms/static/js/dashboard/legacy.js b/lms/static/js/dashboard/legacy.js index 29f7ccb777..0e373512ab 100644 --- a/lms/static/js/dashboard/legacy.js +++ b/lms/static/js/dashboard/legacy.js @@ -224,6 +224,50 @@ return false; }); + $('#send_cta_email').click(function(e) { + $.ajax({ + type: 'POST', + url: urls.sendAccountActivationEmail, + data: $(this).serializeArray(), + success: function() { + $('#activate-account-modal p svg').remove(); + // xss-lint: disable=javascript-jquery-append + $('#activate-account-modal p').append( + // xss-lint: disable=javascript-concat-html + '\n' + + // xss-lint: disable=javascript-concat-html + '\n' + + '' + ); + } + }); + e.preventDefault(); + $('#activate-account-modal p svg').remove(); + // xss-lint: disable=javascript-jquery-append + $('#activate-account-modal p').append( + // xss-lint: disable=javascript-concat-html + '\n' + + // xss-lint: disable=javascript-concat-html + '\n' + + '' + ); + }); + + $('#activate-account-modal').on('click', '#button', function() { + $('#activate-account-modal').css('display', 'none'); + $('#lean_overlay').css({display: 'none'}); + }); + if ($('#activate-account-modal').css('display') === 'block') { + $('#lean_overlay').css({ + display: 'block', + 'z-index': 0 + }); + } + $('.action-email-settings').each(function(index) { $(this).attr('id', 'email-settings-' + index); // a bit of a hack, but gets the unique selector for the modal trigger diff --git a/lms/static/sass/multicourse/_dashboard.scss b/lms/static/sass/multicourse/_dashboard.scss index 7d2161d196..a4d7b63f16 100644 --- a/lms/static/sass/multicourse/_dashboard.scss +++ b/lms/static/sass/multicourse/_dashboard.scss @@ -1583,6 +1583,59 @@ a.fade-cover { } } +#activate-account-modal { + display: block; + position: fixed; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + margin-top: -60px; + text-align: left; + height: 252px; + width: 450px; + box-shadow: none; + background: none; + + .inner-wrapper { + h3 { + font-family: inherit; + padding: 1.5rem 1rem 1rem 1rem; + text-align: left; + font-weight: bold; + font-size: 1.3rem; + line-height: 1.75rem; + } + border: none; + border-radius: 5px; + } +} + +@media (max-width: 460px) and (min-width: 360px) { + #activate-account-modal { + width: 350px; + } +} + +@media (max-width: 360px) { + #activate-account-modal { + width: 300px; + } +} + +.activate-account-modal-button { + text-align: right; + display: block; + padding: 1rem 1rem 1rem 0; + + .btn-primary { + text-transform: none; + font-weight: 500; + } +} +.activate-account-modal-body { + padding: 0 1rem; +} + .reasons_survey { margin: 20px; diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html index 5369df1551..1d416830ec 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -46,7 +46,9 @@ from common.djangoapps.student.models import CourseEnrollment edx.dashboard.legacy.init({ dashboard: "${reverse('dashboard') | n, js_escaped_string}", signInUser: "${reverse('signin_user') | n, js_escaped_string}", - changeEmailSettings: "${reverse('change_email_settings') | n, js_escaped_string}" + changeEmailSettings: "${reverse('change_email_settings') | n, js_escaped_string}", + sendAccountActivationEmail: "${reverse('send_account_activation_email') | n, js_escaped_string}" + }); }); @@ -315,6 +317,35 @@ from common.djangoapps.student.models import CourseEnrollment +%if show_account_activation_popup: + +%endif +