From dc306f8f6d7a6a8dc10b1b3d63e3df64f1c538ad Mon Sep 17 00:00:00 2001 From: adeelehsan Date: Wed, 14 Apr 2021 13:24:56 +0500 Subject: [PATCH] CTA dialogue added VAN-434 --- cms/envs/common.py | 3 ++ common/djangoapps/student/tests/test_email.py | 3 +- common/djangoapps/student/views/dashboard.py | 9 ++++- lms/envs/common.py | 3 ++ lms/static/js/dashboard/legacy.js | 23 ++++++++++++ lms/static/sass/multicourse/_dashboard.scss | 35 +++++++++++++++++++ lms/templates/dashboard.html | 27 +++++++++++++- .../user_authn/api/tests/test_views.py | 32 +++++++++++++++++ .../core/djangoapps/user_authn/api/urls.py | 8 +++-- .../core/djangoapps/user_authn/api/views.py | 30 ++++++++++++++++ .../djangoapps/user_authn/views/register.py | 7 ++++ 11 files changed, 174 insertions(+), 6 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 92a6de11bc..c10ff8844c 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2416,3 +2416,6 @@ 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' diff --git a/common/djangoapps/student/tests/test_email.py b/common/djangoapps/student/tests/test_email.py index 8baac7c80b..67254a0520 100644 --- a/common/djangoapps/student/tests/test_email.py +++ b/common/djangoapps/student/tests/test_email.py @@ -26,8 +26,7 @@ from common.djangoapps.student.views import ( SETTING_CHANGE_INITIATED, confirm_email_change, do_email_change_request, - validate_new_email -) + validate_new_email) from common.djangoapps.third_party_auth.views import inactive_user_view from common.djangoapps.util.testing import EventTestMixin from lms.djangoapps.courseware.toggles import COURSEWARE_PROCTORING_IMPROVEMENTS diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index 0eead5ab38..5a308360ca 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, @@ -772,6 +774,7 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem 'denied_banner': denied_banner, 'billing_email': settings.PAYMENT_SUPPORT_EMAIL, 'user': user, + 'show_account_activation_popup': show_account_activation_popup, 'logout_url': reverse('logout'), 'platform_name': platform_name, 'enrolled_courses_either_paid': enrolled_courses_either_paid, @@ -826,4 +829,8 @@ 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) + + return response diff --git a/lms/envs/common.py b/lms/envs/common.py index e21b9e87d8..9ff3195cca 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -4672,3 +4672,6 @@ 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' diff --git a/lms/static/js/dashboard/legacy.js b/lms/static/js/dashboard/legacy.js index 29f7ccb777..0dba4c9bf9 100644 --- a/lms/static/js/dashboard/legacy.js +++ b/lms/static/js/dashboard/legacy.js @@ -224,6 +224,29 @@ return false; }); + $('#send_cta_email').click(function(e) { + $.ajax({ + type: 'POST', + url: urls.sendAccountActivationEmail, + data: $(this).serializeArray() + }); + e.preventDefault(); + + $('#activate-account-modal').css('display', 'none'); + $('#lean_overlay').css({display: 'none'}); + }); + + $('#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..2eac53fde6 100644 --- a/lms/static/sass/multicourse/_dashboard.scss +++ b/lms/static/sass/multicourse/_dashboard.scss @@ -1583,6 +1583,41 @@ 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 { + 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; + } +} + +.activate-account-modal-button { + text-align: right; + display: block; + padding: 1rem 1rem 1rem 0; +} +.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..9c95db04d1 100644 --- a/lms/templates/dashboard.html +++ b/lms/templates/dashboard.html @@ -5,6 +5,7 @@ <%! import pytz import six +import logging from datetime import datetime, timedelta from django.urls import reverse from django.utils.translation import ugettext as _ @@ -46,7 +47,8 @@ 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}" }); }); @@ -314,6 +316,29 @@ from common.djangoapps.student.models import CourseEnrollment +%if show_account_activation_popup: + +%endif