feat: add DashboardContextEnricher pipeline step for student dashboard filter#2552
feat: add DashboardContextEnricher pipeline step for student dashboard filter#2552
Conversation
…d filter ENT-11569
|
Note for implementer: add openedx-filters to requirements. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2552 +/- ##
==========================================
+ Coverage 85.91% 85.93% +0.02%
==========================================
Files 250 251 +1
Lines 16604 16635 +31
Branches 1639 1640 +1
==========================================
+ Hits 14266 14296 +30
- Misses 2001 2002 +1
Partials 337 337
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1683210 to
ec97806
Compare
|
|
||
| try: | ||
| enterprise_message = get_dashboard_consent_notification(request, user, course_enrollments) | ||
| except Exception: # pylint: disable=broad-except |
There was a problem hiding this comment.
AI added these exception handlers, but I'm not really a fan of them. If we didn't catch exceptions before, let's not just randomly start doing it, especially if we don't even know the specific exception and are forced to disable broad-except which is a bad code smell. Furthermore, swallowing the exception is probably extra bad for visibility of regressions during local/stage testing.
| enterprise learner portal context keys. | ||
| """ | ||
|
|
||
| def run_filter(self, context, template_name): # pylint: disable=arguments-differ |
There was a problem hiding this comment.
Nit: I feel like the function signature should have type hints, at least the inputs for now:
| def run_filter(self, context, template_name): # pylint: disable=arguments-differ | |
| def run_filter(self, context: dict[str, Any], template_name: str): # pylint: disable=arguments-differ |
Just copy the types from the filter itself: https://github.com/openedx/openedx-filters/blob/d517006b0f61050f027de90459e50e2745825992/openedx_filters/learning/filters.py#L829C34-L829C48
Jira: ENT-11569
Summary:
A DashboardContextEnricher pipeline step is defined in enterprise/filters/dashboard.py and injects all enterprise dashboard context keys (enterprise_message, consent_required_courses, is_enterprise_user, and enterprise portal keys). Unit tests cover the pipeline step with enterprise and non-enterprise users.