Skip to content

Commit 87089ed

Browse files
committed
feat: remove enterprise dashboard context imports (ENT-11569)
1 parent 72c2bf6 commit 87089ed

3 files changed

Lines changed: 91 additions & 77 deletions

File tree

common/djangoapps/student/views/dashboard.py

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,31 @@
1717
from django.utils.translation import gettext as _
1818
from django.views.decorators.csrf import ensure_csrf_cookie
1919
from edx_django_utils import monitoring as monitoring_utils
20-
from edx_django_utils.plugins import get_plugins_view_context
20+
from edx_django_utils.plugins import get_plugins_view_context, pluggable_override
2121
from edx_toggles.toggles import WaffleFlag
2222
from opaque_keys.edx.keys import CourseKey
2323
from openedx_filters.learning.filters import DashboardRenderStarted
2424

25-
from edx_django_utils.plugins import pluggable_override
26-
from lms.djangoapps.bulk_email.api import is_bulk_email_feature_enabled
27-
from lms.djangoapps.bulk_email.models import Optout
2825
from common.djangoapps.course_modes.models import CourseMode
2926
from common.djangoapps.edxmako.shortcuts import render_to_response, render_to_string
3027
from common.djangoapps.entitlements.models import CourseEntitlement
28+
from common.djangoapps.student.api import COURSE_DASHBOARD_PLUGIN_VIEW_NAME
29+
from common.djangoapps.student.helpers import cert_info, check_verify_status_by_course, get_resume_urls_for_enrollments
30+
from common.djangoapps.student.models import (
31+
AccountRecovery,
32+
CourseEnrollment,
33+
CourseEnrollmentAttribute,
34+
DashboardConfiguration,
35+
PendingSecondaryEmailChange,
36+
UserProfile
37+
)
38+
from common.djangoapps.util.milestones_helpers import get_pre_requisite_courses_not_completed
39+
from lms.djangoapps.bulk_email.api import is_bulk_email_feature_enabled
40+
from lms.djangoapps.bulk_email.models import Optout
3141
from lms.djangoapps.commerce.utils import EcommerceService
3242
from lms.djangoapps.courseware.access import has_access
33-
from lms.djangoapps.learner_home.waffle import learner_home_mfe_enabled
3443
from lms.djangoapps.experiments.utils import get_dashboard_course_info, get_experiment_user_metadata_context
44+
from lms.djangoapps.learner_home.waffle import learner_home_mfe_enabled
3545
from lms.djangoapps.verify_student.services import IDVerificationService
3646
from openedx.core.djangoapps.catalog.utils import (
3747
get_programs,
@@ -48,23 +58,6 @@
4858
from openedx.core.djangolib.markup import HTML, Text
4959
from openedx.features.content_type_gating.models import ContentTypeGatingConfig
5060
from openedx.features.course_duration_limits.access import get_user_course_duration, get_user_course_expiration_date
51-
from openedx.features.enterprise_support.api import (
52-
get_dashboard_consent_notification,
53-
get_enterprise_learner_portal_context,
54-
)
55-
from openedx.features.enterprise_support.utils import is_enterprise_learner
56-
57-
from common.djangoapps.student.api import COURSE_DASHBOARD_PLUGIN_VIEW_NAME
58-
from common.djangoapps.student.helpers import cert_info, check_verify_status_by_course, get_resume_urls_for_enrollments
59-
from common.djangoapps.student.models import (
60-
AccountRecovery,
61-
CourseEnrollment,
62-
CourseEnrollmentAttribute,
63-
DashboardConfiguration,
64-
PendingSecondaryEmailChange,
65-
UserProfile
66-
)
67-
from common.djangoapps.util.milestones_helpers import get_pre_requisite_courses_not_completed
6861
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
6962

7063
log = logging.getLogger("edx.student")
@@ -621,7 +614,7 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
621614
link_end=HTML("</a>"),
622615
)
623616

624-
enterprise_message = get_dashboard_consent_notification(request, user, course_enrollments)
617+
enterprise_message = ''
625618

626619
recovery_email_message = recovery_email_activation_message = None
627620
if is_secondary_email_feature_enabled():
@@ -649,10 +642,6 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
649642
)
650643
)
651644

652-
# Disable lookup of Enterprise consent_required_course due to ENT-727
653-
# Will re-enable after fixing WL-1315
654-
consent_required_courses = set()
655-
656645
# Account activation message
657646
account_activation_messages = [
658647
message for message in messages.get_messages(request) if 'account-activation' in message.tags
@@ -804,7 +793,7 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
804793
'urls': urls,
805794
'programs_data': programs_data,
806795
'enterprise_message': enterprise_message,
807-
'consent_required_courses': consent_required_courses,
796+
'consent_required_courses': set(),
808797
'enrollment_message': enrollment_message,
809798
'redirect_message': Text(redirect_message),
810799
'account_activation_messages': account_activation_messages,
@@ -854,14 +843,8 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
854843
'course_info': get_dashboard_course_info(user, course_enrollments),
855844
# TODO START: clean up as part of REVEM-199 (END)
856845
'disable_unenrollment': disable_unenrollment,
857-
# TODO: clean when experiment(Merchandise 2U LOBs - Dashboard) would be stop. [VAN-1097]
858-
'is_enterprise_user': is_enterprise_learner(user),
859846
}
860847

861-
# Include enterprise learner portal metadata and messaging
862-
enterprise_learner_portal_context = get_enterprise_learner_portal_context(request)
863-
context.update(enterprise_learner_portal_context)
864-
865848
context_from_plugins = get_plugins_view_context(
866849
ProjectType.LMS,
867850
COURSE_DASHBOARD_PLUGIN_VIEW_NAME,

common/djangoapps/student/views/management.py

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
import datetime
77
import logging
8+
import re
89
import urllib.parse
910
import uuid
1011
from collections import namedtuple
11-
import re
1212
from zoneinfo import ZoneInfo
1313

1414
from django.conf import settings
@@ -26,53 +26,49 @@
2626
from django.urls import reverse
2727
from django.utils.translation import gettext as _
2828
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+
)
3034
from edx_ace import ace
3135
from edx_ace.recipient import Recipient
3236
from edx_django_utils import monitoring as monitoring_utils
3337
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
3540
from eventtracking import tracker
3641
# Note that this lives in LMS, so this dependency should be refactored.
3742
from opaque_keys import InvalidKeyError
3843
from opaque_keys.edx.keys import CourseKey
3944
from rest_framework.decorators import api_view, authentication_classes, permission_classes
4045
from rest_framework.permissions import IsAuthenticated
4146

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
4547
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
6252
)
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
6854
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
7168
from common.djangoapps.student.models import ( # lint-amnesty, pylint: disable=unused-import
7269
AccountRecovery,
7370
CourseEnrollment,
7471
EnrollmentNotAllowed,
75-
PendingEmailChange, # unimport:skip
7672
PendingSecondaryEmailChange,
7773
Registration,
7874
RegistrationCookieConfiguration,
@@ -84,10 +80,30 @@
8480
create_comments_service_user,
8581
email_exists_or_retired
8682
)
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
8886
from common.djangoapps.util.db import outer_atomic
8987
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
91107
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
92108

93109
log = logging.getLogger("edx.student")
@@ -209,7 +225,6 @@ def compose_activation_email(
209225
message_context = generate_activation_email_context(user, user_registration)
210226
message_context.update({
211227
'confirm_activation_link': _get_activation_confirmation_link(message_context['key'], redirect_url),
212-
'is_enterprise_learner': is_enterprise_learner(user),
213228
'is_first_purchase_discount_overridden': FIRST_PURCHASE_DISCOUNT_OVERRIDE_FLAG.is_enabled(),
214229
'route_enabled': route_enabled,
215230
'routed_user': user.username,
@@ -682,7 +697,7 @@ def activate_account(request, key):
682697
url_path = '/login?{}'.format(urllib.parse.urlencode(params))
683698
return redirect(settings.AUTHN_MICROFRONTEND_URL + url_path)
684699

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')
686701
if show_account_activation_popup:
687702
response.delete_cookie(
688703
settings.SHOW_ACTIVATE_CTA_POPUP_COOKIE_NAME,
@@ -739,8 +754,10 @@ def validate_secondary_email(user, new_email):
739754
Enforce valid email addresses.
740755
"""
741756

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,
743759
get_secondary_email_validation_error
760+
)
744761

745762
if get_email_validation_error(new_email):
746763
raise ValueError(_('Valid e-mail address required.'))

lms/envs/common.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,28 @@
4343
import os
4444

4545
from corsheaders.defaults import default_headers as corsheaders_default_headers
46-
from path import Path as path
4746
from django.utils.translation import gettext_lazy as _
4847
from enterprise.constants import (
48+
DEFAULT_ENTERPRISE_ENROLLMENT_INTENTIONS_ROLE,
4949
ENTERPRISE_ADMIN_ROLE,
50-
ENTERPRISE_LEARNER_ROLE,
5150
ENTERPRISE_CATALOG_ADMIN_ROLE,
5251
ENTERPRISE_DASHBOARD_ADMIN_ROLE,
5352
ENTERPRISE_ENROLLMENT_API_ADMIN_ROLE,
5453
ENTERPRISE_FULFILLMENT_OPERATOR_ROLE,
54+
ENTERPRISE_LEARNER_ROLE,
55+
ENTERPRISE_OPERATOR_ROLE,
5556
ENTERPRISE_REPORTING_CONFIG_ADMIN_ROLE,
5657
ENTERPRISE_SSO_ORCHESTRATOR_OPERATOR_ROLE,
57-
ENTERPRISE_OPERATOR_ROLE,
58-
SYSTEM_ENTERPRISE_PROVISIONING_ADMIN_ROLE,
5958
PROVISIONING_ENTERPRISE_CUSTOMER_ADMIN_ROLE,
6059
PROVISIONING_PENDING_ENTERPRISE_CUSTOMER_ADMIN_ROLE,
61-
DEFAULT_ENTERPRISE_ENROLLMENT_INTENTIONS_ROLE,
60+
SYSTEM_ENTERPRISE_PROVISIONING_ADMIN_ROLE
6261
)
6362
from openedx_content.settings_api import openedx_content_backcompat_apps_to_install
63+
from path import Path as path
6464

6565
from openedx.core.lib.derived import Derived
66-
from openedx.envs.common import * # pylint: disable=wildcard-import
67-
6866
from openedx.core.lib.features_setting_proxy import FeaturesProxy
67+
from openedx.envs.common import * # pylint: disable=wildcard-import
6968

7069
# A proxy for feature flags stored in the settings namespace
7170
FEATURES = FeaturesProxy(globals())
@@ -2861,6 +2860,7 @@
28612860
# Note that all settings are actually defined by the plugin
28622861
# pylint: disable=wrong-import-position
28632862
from openedx.core.djangoapps.ace_common.settings import common as ace_common_settings
2863+
28642864
ACE_ROUTING_KEY = ace_common_settings.ACE_ROUTING_KEY
28652865

28662866
############### Settings for facebook ##############################
@@ -2874,8 +2874,13 @@
28742874

28752875
############## Plugin Django Apps #########################
28762876

2877-
from edx_django_utils.plugins import get_plugin_apps, add_plugins # pylint: disable=wrong-import-position,wrong-import-order
2877+
from edx_django_utils.plugins import ( # pylint: disable=wrong-import-position,wrong-import-order
2878+
add_plugins,
2879+
get_plugin_apps
2880+
)
2881+
28782882
from openedx.core.djangoapps.plugins.constants import ProjectType, SettingsType # pylint: disable=wrong-import-position
2883+
28792884
INSTALLED_APPS.extend(get_plugin_apps(ProjectType.LMS))
28802885
add_plugins(__name__, ProjectType.LMS, SettingsType.COMMON)
28812886

@@ -3172,3 +3177,12 @@ def _should_send_certificate_events(settings):
31723177
SSL_AUTH_DN_FORMAT_STRING = (
31733178
"/C=US/ST=Massachusetts/O=Massachusetts Institute of Technology/OU=Client CA v1/CN={0}/emailAddress={1}"
31743179
)
3180+
3181+
########################## OpenEdX Filters Configuration ####################
3182+
3183+
OPEN_EDX_FILTERS_CONFIG = {
3184+
"org.openedx.learning.dashboard.render.started.v1": {
3185+
"fail_silently": True,
3186+
"pipeline": ["enterprise.filters.dashboard.DashboardContextEnricher"],
3187+
},
3188+
}

0 commit comments

Comments
 (0)