refactor: consolidate notifications into dojo/notifications/ package#14767
Open
Maffooch wants to merge 1 commit intoDefectDojo:devfrom
Open
refactor: consolidate notifications into dojo/notifications/ package#14767Maffooch wants to merge 1 commit intoDefectDojo:devfrom
Maffooch wants to merge 1 commit intoDefectDojo:devfrom
Conversation
60d786c to
4791b8a
Compare
Move notification models, admin, services (helper.py), signals, tasks,
settings, context processors, forms, UI views/urls/templates, and API
serializers/viewsets/urls into dojo/notifications/, matching the
canonical dojo/url/ shape from CLAUDE.md.
- Notifications, Notification_Webhooks, Alerts (and constants) extracted
from dojo/models.py into dojo/notifications/models.py; admin moved to
dojo/notifications/admin.py using @admin.register(); registered from
dojo/apps.py ready() to keep model class definition out of the
settings-loading import chain.
- helper.py absorbs process_tag_notifications and sla_compute_and_notify
from dojo/utils.py. All @app.task wrappers (log_generic_alert,
add_alerts, cleanup_alerts, async_sla_compute_and_notify_task,
async_create_notification, send_{slack,msteams,mail,webhooks}_notification,
webhook_reactivation, webhook_status_cleanup) consolidated into
dojo/notifications/tasks.py. async_create_notification calls into
helper.create_notification via lazy import so test patches still apply.
- Default-Notifications-on-User-create logic moved out of dojo/utils.py
into dojo/notifications/signals.py and registered via apps.py ready().
- 7 UI .html templates and 62 channel .tpl templates moved under
dojo/notifications/templates/notifications/. New TEMPLATES DIRS entry
added so notifications/{channel}/{event}.tpl lookups still resolve;
view template_name strings updated where the namespace changed.
- Env-var schema extracted into dojo/notifications/settings.py
(NOTIFICATIONS_ENV_DEFAULTS dict + populate_settings); settings.dist.py
unpacks it into env() and applies values to globals().
- bind_alert_count and session_expiry_notification moved to
dojo/notifications/context_processors.py; TEMPLATES paths updated.
- API NotificationsSerializer/NotificationWebhooksSerializer and
Viewsets relocated under dojo/notifications/api/, exposed via
add_notifications_urls(router) (CLAUDE.md API pattern).
- Celery beat task paths updated to dojo.notifications.tasks.*.
- Backward-compatible re-exports preserved at every original location
(dojo/models.py, dojo/forms.py, dojo/utils.py, dojo/tasks.py,
dojo/context_processors.py, dojo/api_v2/{serializers,views}.py,
dojo/notifications/helper.py).
- No new migrations (string FK references are migration-equivalent).
Verified: manage.py check, makemigrations --check (no diff),
spectacular --fail-on-warn, the notification + cleanup-alerts +
jira-webhook + REST framework test suites pass, and ruff check . is
clean for new code.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4791b8a to
991d3b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
helper.py), signals, tasks, settings, context processors, forms, UI views/urls/templates, and API serializers/viewsets/urls — underdojo/notifications/, matching the canonicaldojo/url/shape fromCLAUDE.md.dojo/models.py,dojo/forms.py,dojo/utils.py,dojo/tasks.py,dojo/context_processors.py,dojo/api_v2/{serializers,views}.py,dojo/notifications/helper.py).dojo/notifications/templates/notifications/(62 channel.tplfiles keep identical lookup names; 7 UI.htmlfiles re-namespaced fromdojo/...htmltonotifications/...html). A new TEMPLATESDIRSentry resolves both trees from the package.NOTIFICATIONS_ENV_DEFAULTS+populate_settings) extracted intodojo/notifications/settings.py;settings.dist.pyconsumes it. Celery beat task paths updated.Test plan
python manage.py check— clean (4 silenced)python manage.py makemigrations --check --dry-run—No changes detectedpython manage.py spectacular --fail-on-warn— cleantest_notifications,test_apiv2_notifications,test_jira_webhook,test_cleanup_alerts,test_rest_framework(1325 tests; all pass, 610 version-skipped)🤖 Generated with Claude Code