Skip to content

Commit 75d63dd

Browse files
authored
feat: removing enterprise code and adding DashboardContextEnricher
1 parent 9e6ef2e commit 75d63dd

9 files changed

Lines changed: 16 additions & 113 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/student/views/management.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
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 require_GET, require_POST # lint-amnesty, pylint: disable=unused-import
3030
from edx_ace import ace
3131
from edx_ace.recipient import Recipient
3232
from edx_django_utils import monitoring as monitoring_utils
@@ -64,7 +64,6 @@
6464
from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser
6565
from openedx.features.course_experience.url_helpers import make_learning_mfe_courseware_url
6666
from openedx.features.discounts.applicability import FIRST_PURCHASE_DISCOUNT_OVERRIDE_FLAG
67-
from openedx.features.enterprise_support.utils import is_enterprise_learner
6867
from common.djangoapps.student.email_helpers import generate_activation_email_context
6968
from common.djangoapps.student.helpers import DISABLE_UNENROLL_CERT_STATES, cert_info
7069
from common.djangoapps.student.message_types import AccountActivation, EmailChange, EmailChangeConfirmation, RecoveryEmailCreate # lint-amnesty, pylint: disable=line-too-long
@@ -209,7 +208,6 @@ def compose_activation_email(
209208
message_context = generate_activation_email_context(user, user_registration)
210209
message_context.update({
211210
'confirm_activation_link': _get_activation_confirmation_link(message_context['key'], redirect_url),
212-
'is_enterprise_learner': is_enterprise_learner(user),
213211
'is_first_purchase_discount_overridden': FIRST_PURCHASE_DISCOUNT_OVERRIDE_FLAG.is_enabled(),
214212
'route_enabled': route_enabled,
215213
'routed_user': user.username,
@@ -682,7 +680,7 @@ def activate_account(request, key):
682680
url_path = '/login?{}'.format(urllib.parse.urlencode(params))
683681
return redirect(settings.AUTHN_MICROFRONTEND_URL + url_path)
684682

685-
response = redirect(redirect_url) if redirect_url and is_enterprise_learner(request.user) else redirect('dashboard')
683+
response = redirect(redirect_url) if redirect_url else redirect('dashboard')
686684
if show_account_activation_popup:
687685
response.delete_cookie(
688686
settings.SHOW_ACTIVATE_CTA_POPUP_COOKIE_NAME,

lms/envs/common.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3773,6 +3773,18 @@ 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+
37763788
############################## Miscellaneous ###############################
37773789

37783790
# 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/core/djangoapps/user_authn/tests/test_tasks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def test_ComposeEmail(self):
4444
assert self.msg.context['routed_user_email'] == self.student.email
4545
assert self.msg.context['routed_profile_name'] == ''
4646
assert self.msg.context['registration_flow'] is False
47-
assert self.msg.context['is_enterprise_learner'] is False
4847
assert self.msg.context['is_first_purchase_discount_overridden'] is False
4948

5049
@mock.patch('time.sleep', mock.Mock(return_value=None))

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)