refactor: deprecated v2 preferences api and its dependencies#38072
refactor: deprecated v2 preferences api and its dependencies#38072AhtishamShahid wants to merge 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the deprecated V2 notification preferences API and the NotificationTypeManager/NotificationAppManager abstractions, consolidating “default preferences” logic into simpler utility functions and aligning terminology around use_app_defaults / grouped notifications.
Changes:
- Removed the V2 aggregated preferences view and URL route, and deleted its associated test coverage.
- Replaced per-app default lookup (
get_default_values_of_preference) with a unifiedget_default_values_of_preferenceshelper and updated call sites. - Updated comments/terminology around “core” notifications to
use_app_defaults/ grouped notifications.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
openedx/core/djangoapps/notifications/views.py |
Removes V2 API view and relies on V3 grouped-notification update flow. |
openedx/core/djangoapps/notifications/urls.py |
Removes the V2 route and import wiring. |
openedx/core/djangoapps/notifications/tests/test_views.py |
Removes V2 view tests and associated imports. |
openedx/core/djangoapps/notifications/tasks.py |
Switches default web-config lookup to the new unified defaults helper. |
openedx/core/djangoapps/notifications/serializers.py |
Removes unused helper and adjusts notification type validation logic. |
openedx/core/djangoapps/notifications/base_notification.py |
Removes manager classes, introduces unified defaults helper usage, and updates terminology/comments. |
Comments suppressed due to low confidence (1)
openedx/core/djangoapps/notifications/base_notification.py:401
get_notification_contentcallsget_default_values_of_preferences(), which rebuilds a merged dict for all notification types on every invocation. SinceNotification.contentuses this during listing/serialization, this can become a hot path. Consider caching the merged mapping (e.g.,functools.lru_cacheor a module-level computed constant) and using that here to avoid repeated per-notification recomputation.
# Retrieve the notification type object from NotificationTypeManager.
notification_type = get_default_values_of_preferences().get(notification_type, None)
if notification_type:
# Check if the notification is grouped.
is_grouped = context.get('grouped', False)
# Determine the correct template key based on whether it's grouped or not.
template_key = "grouped_content_template" if is_grouped else "content_template"
# Get the corresponding template from the notification type.
template = notification_type.get(template_key, None)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fix: Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> fix: resolved linter issues
7fff5e1 to
c8712b1
Compare
|
Hi @kbuchanan-2u Could you confirm whether 2U is using a fork of the edX platform? If so, this deprecation will not affect your implementation. For full details, please refer to the deprecation ticket: Let us know if you have any questions. |
Ticket : #37947
This pull request refactors and simplifies the notification preferences system in the
openedx/core/djangoapps/notificationsmodule. It removes theNotificationTypeManagerandNotificationAppManagerclasses, consolidates logic for retrieving notification preferences, and updates related documentation and function usage. The main goal is to streamline how default notification preferences are accessed and managed, reducing complexity and improving maintainability.Key changes include:
Refactoring and Simplification:
v2/configurationsnotifications APINotificationTypeManagerandNotificationAppManagerclasses, along with their methods for managing notification types and preferences, in favor of a simpler, function-based approach.get_default_values_of_preferencefunction and replaced its usage with the more generalget_default_values_of_preferencesfunction throughout the codebase.Documentation and Naming Updates:
use_app_defaultsreplaces the previous concept of "core" notifications, improving terminology and developer understanding.Code Cleanup:
get_non_editable_channelsfunction from the serializers, further reducing unnecessary code.