Skip to content

Commit 7bd6e04

Browse files
pwnage101kiram15
andauthored
feat: remove enterprise dashboard context imports (#38094)
Co-authored-by: Kira Miller <31229189+kiram15@users.noreply.github.com>
1 parent ff88201 commit 7bd6e04

7 files changed

Lines changed: 6 additions & 107 deletions

File tree

common/djangoapps/student/views/dashboard.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@
5858
from openedx.core.djangolib.markup import HTML, Text
5959
from openedx.features.content_type_gating.models import ContentTypeGatingConfig
6060
from openedx.features.course_duration_limits.access import get_user_course_duration, get_user_course_expiration_date
61-
from openedx.features.enterprise_support.api import (
62-
get_dashboard_consent_notification,
63-
get_enterprise_learner_portal_context,
64-
)
65-
from openedx.features.enterprise_support.utils import is_enterprise_learner
6661
from xmodule.modulestore.django import modulestore # pylint: disable=wrong-import-order
6762

6863
log = logging.getLogger("edx.student")
@@ -619,8 +614,6 @@ def student_dashboard(request): # pylint: disable=too-many-statements
619614
link_end=HTML("</a>"),
620615
)
621616

622-
enterprise_message = get_dashboard_consent_notification(request, user, course_enrollments)
623-
624617
recovery_email_message = recovery_email_activation_message = None
625618
if is_secondary_email_feature_enabled():
626619
try:
@@ -647,10 +640,6 @@ def student_dashboard(request): # pylint: disable=too-many-statements
647640
)
648641
)
649642

650-
# Disable lookup of Enterprise consent_required_course due to ENT-727
651-
# Will re-enable after fixing WL-1315
652-
consent_required_courses = set()
653-
654643
# Account activation message
655644
account_activation_messages = [
656645
message for message in messages.get_messages(request) if 'account-activation' in message.tags
@@ -801,8 +790,6 @@ def student_dashboard(request): # pylint: disable=too-many-statements
801790
context = {
802791
'urls': urls,
803792
'programs_data': programs_data,
804-
'enterprise_message': enterprise_message,
805-
'consent_required_courses': consent_required_courses,
806793
'enrollment_message': enrollment_message,
807794
'redirect_message': Text(redirect_message),
808795
'account_activation_messages': account_activation_messages,
@@ -852,14 +839,8 @@ def student_dashboard(request): # pylint: disable=too-many-statements
852839
'course_info': get_dashboard_course_info(user, course_enrollments),
853840
# TODO START: clean up as part of REVEM-199 (END)
854841
'disable_unenrollment': disable_unenrollment,
855-
# TODO: clean when experiment(Merchandise 2U LOBs - Dashboard) would be stop. [VAN-1097]
856-
'is_enterprise_user': is_enterprise_learner(user),
857842
}
858843

859-
# Include enterprise learner portal metadata and messaging
860-
enterprise_learner_portal_context = get_enterprise_learner_portal_context(request)
861-
context.update(enterprise_learner_portal_context)
862-
863844
context_from_plugins = get_plugins_view_context(
864845
ProjectType.LMS,
865846
COURSE_DASHBOARD_PLUGIN_VIEW_NAME,

lms/envs/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,6 +3291,10 @@ def _should_send_certificate_events(settings):
32913291
"fail_silently": True,
32923292
"pipeline": ["enterprise.filters.accounts.AccountSettingsReadOnlyFieldsStep"],
32933293
},
3294+
"org.openedx.learning.dashboard.render.started.v1": {
3295+
"fail_silently": False,
3296+
"pipeline": ["enterprise.filters.dashboard.DashboardContextEnricher"],
3297+
},
32943298
}
32953299

32963300
############################## Miscellaneous ###############################

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
@@ -711,29 +711,6 @@ def consent_needed_for_course(request, user, course_id, enrollment_exists=False)
711711
return True
712712

713713

714-
@enterprise_is_enabled(otherwise=set())
715-
def get_consent_required_courses(user, course_ids):
716-
"""
717-
Returns a set of course_ids that require consent
718-
Note that this function makes use of the Enterprise models directly instead of using the API calls
719-
"""
720-
result = set()
721-
enterprise_learner = EnterpriseCustomerUser.objects.filter(user_id=user.id).first()
722-
if not enterprise_learner or not enterprise_learner.enterprise_customer:
723-
return result
724-
725-
enterprise_uuid = enterprise_learner.enterprise_customer.uuid
726-
data_sharing_consent = DataSharingConsent.objects.filter(username=user.username,
727-
course_id__in=course_ids,
728-
enterprise_customer__uuid=enterprise_uuid)
729-
730-
for consent in data_sharing_consent:
731-
if consent.consent_required():
732-
result.add(consent.course_id)
733-
734-
return result
735-
736-
737714
@enterprise_is_enabled(otherwise='')
738715
def get_enterprise_consent_url(request, course_id, user=None, return_to=None, enrollment_exists=False, source='lms'):
739716
"""

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)