refactor: consolidate notifications into dojo/notifications/ package#14767
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
valentijnscholten
left a comment
There was a problem hiding this comment.
What does this PR mean for users that have customized their templates?
|
They will need to change their templates - I can add some breaking changes to the release notes |
…tion template relocation details
|
My question was about the tpl files and it looks like no action is needed for people who modified those? |
|
Yeah most folks will likely not be impacted. The tpl files are changing locations, so if there folks with custom template downstream, and then update to the new version, the default tpl files will be read rather than the custom ones. So the action required for users that have modified those templates will be to move them to the new location. |
|
For me it's not clear from the added upgrade notes that users need to move their customized templates (and where). |
… notification .tpl templates relocation
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
# Conflicts: # dojo/models.py # dojo/settings/settings.dist.py
|
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Pulls in 15 upstream commits including: * dojo/sso/ consolidation (DefectDojo#14765) — SSO settings/urls/views/templates/ remote-user moved into a self-contained package. * dojo/notifications/ consolidation (DefectDojo#14767) — notification helper + templates moved into the package, with a new context_processors split. * dojo/github/ consolidation (DefectDojo#14766) — github_issue_link package renamed and reshaped under dojo/github/{models,services,ui,...}. * test_tag_inheritance.py extension (DefectDojo#14771). * Bulk-delete findings extension hook (DefectDojo#14740). * Planned-remediation-version column alignment fix (DefectDojo#14773). * Dependency bumps (datatables.net, gitpython, python-gitlab, pyopenssl, vulners, ruff, postcss). Conflict resolutions worth flagging: * dojo/forms.py — kept dev's reshuffled imports (GITHUB_* models now re-exported via dojo.github.ui.forms; Global_Role moved to dojo.models). Dropped the duplicate Global_Role import; the legacy authorization rewrite still imports from dojo.authorization.models for the rest. * dojo/settings/settings.dist.py — kept tailwind's UIPreferenceLoader chain and APP_DIRS=False, but added a shared _DOJO_EXTRA_TEMPLATE_DIRS list referenced by both TEMPLATES[0]["DIRS"] and the FilesystemLoader so that dojo/sso/settings.py:apply_sso_settings can append the SSO template dir at startup and have it resolved at render time. * dojo/templates/dojo/login.html — Tailwind tree, kept the inline Tailwind-styled SSO buttons rather than dev's {% include "dojo/sso_login_buttons.html" %} (which is Bootstrap-classic flavored and mounted by the SSO consolidation against the classic tree only). * unittests/test_remote_user.py — adopted dev's import path (dojo.sso.remote_user, dojo.models.Dojo_Group_Member). * dojo/api_v2/permissions.py — added a backward-compat shim re-exporting from dojo.authorization.api_permissions because the legacy authorization consolidation deleted the old module but dojo/notifications/api/views.py (new from dev) still imports from the old path. Verified: ruff clean on touched files; manage.py check passes; unittests.test_authorized_users_ui + unittests.authorization + unittests.test_user_ui_timestamps + unittests.test_rest_framework + unittests.test_remote_user all green (1144 tests, 542 skipped).
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