|
5 | 5 |
|
6 | 6 | import datetime |
7 | 7 | import logging |
| 8 | +import re |
8 | 9 | import urllib.parse |
9 | 10 | import uuid |
10 | 11 | from collections import namedtuple |
11 | | -import re |
12 | 12 | from zoneinfo import ZoneInfo |
13 | 13 |
|
14 | 14 | from django.conf import settings |
|
26 | 26 | from django.urls import reverse |
27 | 27 | from django.utils.translation import gettext as _ |
28 | 28 | from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie # lint-amnesty, pylint: disable=unused-import |
29 | | -from django.views.decorators.http import require_GET, require_http_methods, require_POST # lint-amnesty, pylint: disable=unused-import |
| 29 | +from django.views.decorators.http import ( # lint-amnesty, pylint: disable=unused-import |
| 30 | + require_GET, |
| 31 | + require_http_methods, |
| 32 | + require_POST |
| 33 | +) |
30 | 34 | from edx_ace import ace |
31 | 35 | from edx_ace.recipient import Recipient |
32 | 36 | from edx_django_utils import monitoring as monitoring_utils |
33 | 37 | from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication |
34 | | -from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser # lint-amnesty, pylint: disable=wrong-import-order |
| 38 | +from edx_rest_framework_extensions.auth.session.authentication import \ |
| 39 | + SessionAuthenticationAllowInactiveUser # lint-amnesty, pylint: disable=wrong-import-order |
35 | 40 | from eventtracking import tracker |
36 | 41 | # Note that this lives in LMS, so this dependency should be refactored. |
37 | 42 | from opaque_keys import InvalidKeyError |
38 | 43 | from opaque_keys.edx.keys import CourseKey |
39 | 44 | from rest_framework.decorators import api_view, authentication_classes, permission_classes |
40 | 45 | from rest_framework.permissions import IsAuthenticated |
41 | 46 |
|
42 | | -from common.djangoapps.student.toggles import should_redirect_to_courseware_after_enrollment |
43 | | -from common.djangoapps.track import views as track_views |
44 | | -from lms.djangoapps.bulk_email.models import Optout |
45 | 47 | from common.djangoapps.course_modes.models import CourseMode |
46 | | -from lms.djangoapps.courseware.courses import get_courses, sort_by_announcement, sort_by_start_date |
47 | | -from common.djangoapps.edxmako.shortcuts import marketing_link, render_to_response, render_to_string # lint-amnesty, pylint: disable=unused-import |
48 | | -from common.djangoapps.entitlements.models import CourseEntitlement |
49 | | -from common.djangoapps.student.helpers import get_next_url_for_login_page, get_redirect_url_with_host |
50 | | -from openedx.core.djangoapps.ace_common.template_context import get_base_template_context |
51 | | -from openedx.core.djangoapps.catalog.utils import get_programs_with_type |
52 | | -from openedx.core.djangoapps.embargo import api as embargo_api |
53 | | -from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY |
54 | | -from openedx.core.djangoapps.programs.models import ProgramsApiConfig # lint-amnesty, pylint: disable=unused-import |
55 | | -from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers |
56 | | -from openedx.core.djangoapps.theming import helpers as theming_helpers |
57 | | -from openedx.core.djangoapps.user_api.preferences import api as preferences_api |
58 | | -from openedx.core.djangoapps.user_authn.tasks import send_activation_email |
59 | | -from openedx.core.djangoapps.user_authn.toggles import ( |
60 | | - should_redirect_to_authn_microfrontend, |
61 | | - is_auto_generated_username_enabled |
| 48 | +from common.djangoapps.edxmako.shortcuts import ( # lint-amnesty, pylint: disable=unused-import |
| 49 | + marketing_link, |
| 50 | + render_to_response, |
| 51 | + render_to_string |
62 | 52 | ) |
63 | | -from openedx.core.djangolib.markup import HTML, Text |
64 | | -from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser |
65 | | -from openedx.features.course_experience.url_helpers import make_learning_mfe_courseware_url |
66 | | -from openedx.features.discounts.applicability import FIRST_PURCHASE_DISCOUNT_OVERRIDE_FLAG |
67 | | -from openedx.features.enterprise_support.utils import is_enterprise_learner |
| 53 | +from common.djangoapps.entitlements.models import CourseEntitlement |
68 | 54 | from common.djangoapps.student.email_helpers import generate_activation_email_context |
69 | | -from common.djangoapps.student.helpers import DISABLE_UNENROLL_CERT_STATES, cert_info |
70 | | -from common.djangoapps.student.message_types import AccountActivation, EmailChange, EmailChangeConfirmation, RecoveryEmailCreate # lint-amnesty, pylint: disable=line-too-long |
| 55 | +from common.djangoapps.student.helpers import ( |
| 56 | + DISABLE_UNENROLL_CERT_STATES, |
| 57 | + cert_info, |
| 58 | + get_next_url_for_login_page, |
| 59 | + get_redirect_url_with_host |
| 60 | +) |
| 61 | +from common.djangoapps.student.message_types import ( # lint-amnesty, pylint: disable=line-too-long |
| 62 | + AccountActivation, |
| 63 | + EmailChange, |
| 64 | + EmailChangeConfirmation, |
| 65 | + RecoveryEmailCreate |
| 66 | +) |
| 67 | +from common.djangoapps.student.models import PendingEmailChange # unimport:skip |
71 | 68 | from common.djangoapps.student.models import ( # lint-amnesty, pylint: disable=unused-import |
72 | 69 | AccountRecovery, |
73 | 70 | CourseEnrollment, |
74 | 71 | EnrollmentNotAllowed, |
75 | | - PendingEmailChange, # unimport:skip |
76 | 72 | PendingSecondaryEmailChange, |
77 | 73 | Registration, |
78 | 74 | RegistrationCookieConfiguration, |
|
84 | 80 | create_comments_service_user, |
85 | 81 | email_exists_or_retired |
86 | 82 | ) |
87 | | -from common.djangoapps.student.signals import REFUND_ORDER |
| 83 | +from common.djangoapps.student.signals import REFUND_ORDER, USER_EMAIL_CHANGED |
| 84 | +from common.djangoapps.student.toggles import should_redirect_to_courseware_after_enrollment |
| 85 | +from common.djangoapps.track import views as track_views |
88 | 86 | from common.djangoapps.util.db import outer_atomic |
89 | 87 | from common.djangoapps.util.json_request import JsonResponse |
90 | | -from common.djangoapps.student.signals import USER_EMAIL_CHANGED |
| 88 | +from lms.djangoapps.bulk_email.models import Optout |
| 89 | +from lms.djangoapps.courseware.courses import get_courses, sort_by_announcement, sort_by_start_date |
| 90 | +from openedx.core.djangoapps.ace_common.template_context import get_base_template_context |
| 91 | +from openedx.core.djangoapps.catalog.utils import get_programs_with_type |
| 92 | +from openedx.core.djangoapps.embargo import api as embargo_api |
| 93 | +from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY |
| 94 | +from openedx.core.djangoapps.programs.models import ProgramsApiConfig # lint-amnesty, pylint: disable=unused-import |
| 95 | +from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers |
| 96 | +from openedx.core.djangoapps.theming import helpers as theming_helpers |
| 97 | +from openedx.core.djangoapps.user_api.preferences import api as preferences_api |
| 98 | +from openedx.core.djangoapps.user_authn.tasks import send_activation_email |
| 99 | +from openedx.core.djangoapps.user_authn.toggles import ( |
| 100 | + is_auto_generated_username_enabled, |
| 101 | + should_redirect_to_authn_microfrontend |
| 102 | +) |
| 103 | +from openedx.core.djangolib.markup import HTML, Text |
| 104 | +from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser |
| 105 | +from openedx.features.course_experience.url_helpers import make_learning_mfe_courseware_url |
| 106 | +from openedx.features.discounts.applicability import FIRST_PURCHASE_DISCOUNT_OVERRIDE_FLAG |
91 | 107 | from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order |
92 | 108 |
|
93 | 109 | log = logging.getLogger("edx.student") |
@@ -209,7 +225,6 @@ def compose_activation_email( |
209 | 225 | message_context = generate_activation_email_context(user, user_registration) |
210 | 226 | message_context.update({ |
211 | 227 | 'confirm_activation_link': _get_activation_confirmation_link(message_context['key'], redirect_url), |
212 | | - 'is_enterprise_learner': is_enterprise_learner(user), |
213 | 228 | 'is_first_purchase_discount_overridden': FIRST_PURCHASE_DISCOUNT_OVERRIDE_FLAG.is_enabled(), |
214 | 229 | 'route_enabled': route_enabled, |
215 | 230 | 'routed_user': user.username, |
@@ -682,7 +697,7 @@ def activate_account(request, key): |
682 | 697 | url_path = '/login?{}'.format(urllib.parse.urlencode(params)) |
683 | 698 | return redirect(settings.AUTHN_MICROFRONTEND_URL + url_path) |
684 | 699 |
|
685 | | - response = redirect(redirect_url) if redirect_url and is_enterprise_learner(request.user) else redirect('dashboard') |
| 700 | + response = redirect(redirect_url) if redirect_url else redirect('dashboard') |
686 | 701 | if show_account_activation_popup: |
687 | 702 | response.delete_cookie( |
688 | 703 | settings.SHOW_ACTIVATE_CTA_POPUP_COOKIE_NAME, |
@@ -739,8 +754,10 @@ def validate_secondary_email(user, new_email): |
739 | 754 | Enforce valid email addresses. |
740 | 755 | """ |
741 | 756 |
|
742 | | - from openedx.core.djangoapps.user_api.accounts.api import get_email_validation_error, \ |
| 757 | + from openedx.core.djangoapps.user_api.accounts.api import ( |
| 758 | + get_email_validation_error, |
743 | 759 | get_secondary_email_validation_error |
| 760 | + ) |
744 | 761 |
|
745 | 762 | if get_email_validation_error(new_email): |
746 | 763 | raise ValueError(_('Valid e-mail address required.')) |
|
0 commit comments