Skip to content

Commit 7dd11f7

Browse files
authored
feat: remove enterprise dashboard context imports (#270)
1 parent 0a9329d commit 7dd11f7

8 files changed

Lines changed: 16 additions & 109 deletions

File tree

common/djangoapps/student/views/dashboard.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@
4848
from openedx.core.djangolib.markup import HTML, Text
4949
from openedx.features.content_type_gating.models import ContentTypeGatingConfig
5050
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-
5751
from common.djangoapps.student.api import COURSE_DASHBOARD_PLUGIN_VIEW_NAME
5852
from common.djangoapps.student.helpers import cert_info, check_verify_status_by_course, get_resume_urls_for_enrollments
5953
from common.djangoapps.student.models import (
@@ -617,8 +611,6 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
617611
link_end=HTML("</a>"),
618612
)
619613

620-
enterprise_message = get_dashboard_consent_notification(request, user, course_enrollments)
621-
622614
recovery_email_message = recovery_email_activation_message = None
623615
if is_secondary_email_feature_enabled():
624616
try:
@@ -645,10 +637,6 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
645637
)
646638
)
647639

648-
# Disable lookup of Enterprise consent_required_course due to ENT-727
649-
# Will re-enable after fixing WL-1315
650-
consent_required_courses = set()
651-
652640
# Account activation message
653641
account_activation_messages = [
654642
message for message in messages.get_messages(request) if 'account-activation' in message.tags
@@ -799,8 +787,6 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
799787
context = {
800788
'urls': urls,
801789
'programs_data': programs_data,
802-
'enterprise_message': enterprise_message,
803-
'consent_required_courses': consent_required_courses,
804790
'enrollment_message': enrollment_message,
805791
'redirect_message': Text(redirect_message),
806792
'account_activation_messages': account_activation_messages,
@@ -850,14 +836,8 @@ def student_dashboard(request): # lint-amnesty, pylint: disable=too-many-statem
850836
'course_info': get_dashboard_course_info(user, course_enrollments),
851837
# TODO START: clean up as part of REVEM-199 (END)
852838
'disable_unenrollment': disable_unenrollment,
853-
# TODO: clean when experiment(Merchandise 2U LOBs - Dashboard) would be stop. [VAN-1097]
854-
'is_enterprise_user': is_enterprise_learner(user),
855839
}
856840

857-
# Include enterprise learner portal metadata and messaging
858-
enterprise_learner_portal_context = get_enterprise_learner_portal_context(request)
859-
context.update(enterprise_learner_portal_context)
860-
861841
context_from_plugins = get_plugins_view_context(
862842
ProjectType.LMS,
863843
COURSE_DASHBOARD_PLUGIN_VIEW_NAME,

common/djangoapps/third_party_auth/pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def B(*args, **kwargs):
9393
from openedx.core.djangoapps.user_authn import cookies as user_authn_cookies
9494
from openedx.core.djangoapps.user_authn.toggles import is_auto_generated_username_enabled
9595
from openedx.core.djangoapps.user_authn.utils import is_safe_login_or_logout_redirect
96-
from openedx.core.djangoapps.user_authn.views.utils import get_auto_generated_username
9796
from common.djangoapps.third_party_auth.utils import (
9897
get_associated_user_by_email_response,
9998
is_oauth_provider,
@@ -958,6 +957,7 @@ def get_username(strategy, details, backend, user=None, *args, **kwargs): # lin
958957
slug_func = lambda val: val
959958

960959
if is_auto_generated_username_enabled() and details.get('username') is None:
960+
from openedx.core.djangoapps.user_authn.views.utils import get_auto_generated_username # pylint: disable=import-outside-toplevel
961961
username = get_auto_generated_username(details)
962962
else:
963963
if email_as_username and details.get('email'):

lms/envs/common.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3773,6 +3773,19 @@ def _should_send_certificate_events(settings):
37733773
# The project ID should be obtained from the Google Cloud Console when creating a reCAPTCHA
37743774
RECAPTCHA_PROJECT_ID = None
37753775

3776+
# .. setting_name: OPEN_EDX_FILTERS_CONFIG
3777+
# .. setting_default: {}
3778+
# .. setting_description: Configuration dict for openedx-filters pipeline steps.
3779+
# Keys are filter type strings; values are dicts with 'fail_silently' (bool) and
3780+
# 'pipeline' (list of dotted-path strings to PipelineStep subclasses).
3781+
OPEN_EDX_FILTERS_CONFIG = {
3782+
"org.openedx.learning.dashboard.render.started.v1": {
3783+
"fail_silently": False,
3784+
"pipeline": ["enterprise.filters.dashboard.DashboardContextEnricher"],
3785+
},
3786+
}
3787+
3788+
37763789
############################## Miscellaneous ###############################
37773790

37783791
# To limit the number of courses displayed on learner dashboard

lms/templates/dashboard.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,9 @@
220220
is_course_voucher_refundable = (session_id in enrolled_courses_voucher_refundable)
221221
course_requirements = courses_requirements_not_met.get(session_id)
222222
related_programs = inverted_programs.get(str(entitlement.course_uuid if is_unfulfilled_entitlement else session_id))
223-
show_consent_link = (session_id in consent_required_courses)
224223
resume_button_url = resume_button_urls[dashboard_index]
225224
%>
226-
<%include file='dashboard/_dashboard_course_listing.html' args='course_overview=course_overview, course_card_index=dashboard_index, enrollment=enrollment, enrollments_fbe_is_on=enrollments_fbe_is_on, is_unfulfilled_entitlement=is_unfulfilled_entitlement, is_fulfilled_entitlement=is_fulfilled_entitlement, entitlement=entitlement, entitlement_session=entitlement_session, entitlement_available_sessions=entitlement_available_sessions, entitlement_expiration_date=entitlement_expiration_date, entitlement_expired_at=entitlement_expired_at, show_courseware_link=show_courseware_link, cert_status=cert_status, can_refund_entitlement=can_refund_entitlement, can_unenroll=can_unenroll, credit_status=credit_status, show_email_settings=show_email_settings, course_mode_info=course_mode_info, is_paid_course=is_paid_course, is_course_voucher_refundable=is_course_voucher_refundable, course_requirements=course_requirements, dashboard_index=dashboard_index, share_settings=share_settings, user=user, related_programs=related_programs, display_course_modes_on_dashboard=display_course_modes_on_dashboard, show_consent_link=show_consent_link, enterprise_customer_name=enterprise_customer_name, resume_button_url=resume_button_url, partner_managed_enrollment=partner_managed_enrollment' />
225+
<%include file='dashboard/_dashboard_course_listing.html' args='course_overview=course_overview, course_card_index=dashboard_index, enrollment=enrollment, enrollments_fbe_is_on=enrollments_fbe_is_on, is_unfulfilled_entitlement=is_unfulfilled_entitlement, is_fulfilled_entitlement=is_fulfilled_entitlement, entitlement=entitlement, entitlement_session=entitlement_session, entitlement_available_sessions=entitlement_available_sessions, entitlement_expiration_date=entitlement_expiration_date, entitlement_expired_at=entitlement_expired_at, show_courseware_link=show_courseware_link, cert_status=cert_status, can_refund_entitlement=can_refund_entitlement, can_unenroll=can_unenroll, credit_status=credit_status, show_email_settings=show_email_settings, course_mode_info=course_mode_info, is_paid_course=is_paid_course, is_course_voucher_refundable=is_course_voucher_refundable, course_requirements=course_requirements, dashboard_index=dashboard_index, share_settings=share_settings, user=user, related_programs=related_programs, display_course_modes_on_dashboard=display_course_modes_on_dashboard, resume_button_url=resume_button_url, partner_managed_enrollment=partner_managed_enrollment' />
227226
% endfor
228227
% if show_load_all_courses_link:
229228
<br/>

lms/templates/dashboard/_dashboard_course_listing.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%page args="course_overview, enrollment, entitlement, entitlement_session, course_card_index, enrollments_fbe_is_on, is_unfulfilled_entitlement, is_fulfilled_entitlement, entitlement_available_sessions, entitlement_expiration_date, entitlement_expired_at, show_courseware_link, cert_status, can_refund_entitlement, can_unenroll, credit_status, show_email_settings, course_mode_info, is_paid_course, is_course_voucher_refundable, course_requirements, dashboard_index, share_settings, related_programs, display_course_modes_on_dashboard, show_consent_link, enterprise_customer_name, resume_button_url, partner_managed_enrollment" expression_filter="h"/>
1+
<%page args="course_overview, enrollment, entitlement, entitlement_session, course_card_index, enrollments_fbe_is_on, is_unfulfilled_entitlement, is_fulfilled_entitlement, entitlement_available_sessions, entitlement_expiration_date, entitlement_expired_at, show_courseware_link, cert_status, can_refund_entitlement, can_unenroll, credit_status, show_email_settings, course_mode_info, is_paid_course, is_course_voucher_refundable, course_requirements, dashboard_index, share_settings, related_programs, display_course_modes_on_dashboard, resume_button_url, partner_managed_enrollment" expression_filter="h"/>
22

33
<%!
44
import datetime
@@ -370,10 +370,6 @@ <h3 class="course-title" id="course-title-${enrollment.course_id}">
370370
<%include file="_dashboard_credit_info.html" args="credit_status=credit_status"/>
371371
% endif
372372

373-
% if show_consent_link:
374-
<%include file="_dashboard_show_consent.html" args="course_overview=course_overview, course_target=course_target, enrollment=enrollment, enterprise_customer_name=enterprise_customer_name"/>
375-
%endif
376-
377373
% if display_course_upgrade:
378374
<div class="message message-upsell has-actions is-shown">
379375
<div class="wrapper-extended">

lms/templates/dashboard/_dashboard_show_consent.html

Lines changed: 0 additions & 25 deletions
This file was deleted.

openedx/features/enterprise_support/api.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -723,29 +723,6 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
723723
return True
724724

725725

726-
@enterprise_is_enabled(otherwise=set())
727-
def get_consent_required_courses(user, course_ids):
728-
"""
729-
Returns a set of course_ids that require consent
730-
Note that this function makes use of the Enterprise models directly instead of using the API calls
731-
"""
732-
result = set()
733-
enterprise_learner = EnterpriseCustomerUser.objects.filter(user_id=user.id).first()
734-
if not enterprise_learner or not enterprise_learner.enterprise_customer:
735-
return result
736-
737-
enterprise_uuid = enterprise_learner.enterprise_customer.uuid
738-
data_sharing_consent = DataSharingConsent.objects.filter(username=user.username,
739-
course_id__in=course_ids,
740-
enterprise_customer__uuid=enterprise_uuid)
741-
742-
for consent in data_sharing_consent:
743-
if consent.consent_required():
744-
result.add(consent.course_id)
745-
746-
return result
747-
748-
749726
@enterprise_is_enabled(otherwise='')
750727
def get_enterprise_consent_url(request, course_id, user=None, return_to=None, enrollment_exists=False, source='lms'):
751728
"""

openedx/features/enterprise_support/tests/test_api.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
enterprise_enabled,
4242
get_active_enterprise_customer_user,
4343
get_consent_notification_data,
44-
get_consent_required_courses,
4544
get_dashboard_consent_notification,
4645
get_data_sharing_consents,
4746
get_enterprise_consent_url,
@@ -530,38 +529,6 @@ def test_consent_needed_for_course_when_consent_is_required(
530529
)
531530
)
532531

533-
@httpretty.activate
534-
@mock.patch('enterprise.models.EnterpriseCustomer.catalog_contains_course')
535-
def test_get_consent_required_courses(self, mock_catalog_contains_course):
536-
mock_catalog_contains_course.return_value = True
537-
user = UserFactory()
538-
enterprise_customer_user = EnterpriseCustomerUserFactory(user_id=user.id)
539-
540-
course_id = 'fake-course'
541-
data_sharing_consent = DataSharingConsent(
542-
course_id=course_id,
543-
enterprise_customer=enterprise_customer_user.enterprise_customer,
544-
username=user.username,
545-
granted=False
546-
)
547-
data_sharing_consent.save()
548-
consent_required = get_consent_required_courses(user, [course_id])
549-
assert course_id in consent_required
550-
551-
# now grant consent and call our method again
552-
data_sharing_consent.granted = True
553-
data_sharing_consent.save()
554-
consent_required = get_consent_required_courses(user, [course_id])
555-
assert course_id not in consent_required
556-
557-
def test_consent_not_required_for_non_enterprise_user(self):
558-
user = UserFactory()
559-
course_id = 'fake-course'
560-
561-
consent_required_courses = get_consent_required_courses(user, [course_id])
562-
563-
assert set() == consent_required_courses
564-
565532
@mock.patch('openedx.features.enterprise_support.api.create_jwt_for_user')
566533
def test_fetch_enterprise_learner_data_unauthenticated(self, mock_jwt_builder):
567534
api_client = self._assert_api_client_with_user(EnterpriseApiClient, mock_jwt_builder)

0 commit comments

Comments
 (0)