Skip to content

refactor: consolidate notifications into dojo/notifications/ package#14767

Open
Maffooch wants to merge 1 commit intoDefectDojo:devfrom
Maffooch:worktree-concurrent-chasing-piglet
Open

refactor: consolidate notifications into dojo/notifications/ package#14767
Maffooch wants to merge 1 commit intoDefectDojo:devfrom
Maffooch:worktree-concurrent-chasing-piglet

Conversation

@Maffooch
Copy link
Copy Markdown
Contributor

Summary

  • Consolidates the entire notification domain — models, admin, services (helper.py), signals, tasks, settings, context processors, forms, UI views/urls/templates, and API serializers/viewsets/urls — under dojo/notifications/, matching the canonical dojo/url/ shape from CLAUDE.md.
  • 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).
  • 69 templates relocated into dojo/notifications/templates/notifications/ (62 channel .tpl files keep identical lookup names; 7 UI .html files re-namespaced from dojo/...html to notifications/...html). A new TEMPLATES DIRS entry resolves both trees from the package.
  • Notification env-var schema (NOTIFICATIONS_ENV_DEFAULTS + populate_settings) extracted into dojo/notifications/settings.py; settings.dist.py consumes it. Celery beat task paths updated.
  • No new migrations — string FK references in the relocated models are migration-equivalent to the original class references.

Test plan

  • python manage.py check — clean (4 silenced)
  • python manage.py makemigrations --check --dry-runNo changes detected
  • python manage.py spectacular --fail-on-warn — clean
  • Pytest: test_notifications, test_apiv2_notifications, test_jira_webhook, test_cleanup_alerts, test_rest_framework (1325 tests; all pass, 610 version-skipped)
  • CI passes
  • Smoke-test in dev: trigger a finding save and confirm Slack/email/webhook channels still fire end-to-end

🤖 Generated with Claude Code

@Maffooch Maffooch requested a review from mtesauro as a code owner April 27, 2026 22:27
@github-actions github-actions Bot added settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR apiv2 unittests labels Apr 27, 2026
@Maffooch Maffooch changed the title Consolidate notifications into dojo/notifications/ package refactor: consolidate notifications into dojo/notifications/ package Apr 27, 2026
@Maffooch Maffooch force-pushed the worktree-concurrent-chasing-piglet branch from 60d786c to 4791b8a Compare April 27, 2026 22:39
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>
@Maffooch Maffooch force-pushed the worktree-concurrent-chasing-piglet branch from 4791b8a to 991d3b7 Compare April 27, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apiv2 settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR unittests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant