Skip to content

refactor(engagement): Extract Test models into dojo/test/ module [3/10]#14972

Draft
valentijnscholten wants to merge 5 commits into
reorg/test-modelsfrom
reorg/engagement-models
Draft

refactor(engagement): Extract Test models into dojo/test/ module [3/10]#14972
valentijnscholten wants to merge 5 commits into
reorg/test-modelsfrom
reorg/engagement-models

Conversation

@valentijnscholten

@valentijnscholten valentijnscholten commented Jun 7, 2026

Copy link
Copy Markdown
Member

Stacked PRs

This is one of a stacked series that reorganizes dojo/ into self-contained dojo/{module}/ packages (matching the dojo/url/ reference). They are stacked — each PR is based on the previous one — so review and merge bottom-up in this order:

  1. refactor(product_type): Extra ProductType models into dojo/product_type/ module [1/10] #14970 — product_type
  2. refactor(test): Extract Test models into dojo/test/ module [2/10] #14971 — test
  3. refactor(engagement): Extract Test models into dojo/test/ module [3/10] #14972 — engagement ◀ this PR
  4. refactor(product): Extract Product module into dojo/product/ [4/10] #14973 — product
  5. refactor(finding): Reorganize finding into self-contained dojo/finding/ package [5/10] #14974 — finding (+ CWE & BurpRawRequestResponse fold-in)
  6. refactor(reorg): extract user + system_settings modules [6/10] #14981 — peripheral: user + system_settings
  7. refactor(reorg): extract endpoint + tool_type/tool_config/tool_product modules [7/10] #14982 — peripheral: endpoint + tool_type/tool_config/tool_product
  8. refactor(reorg): extract survey + benchmark modules [8/10] #14983 — peripheral: survey + benchmark
  9. refactor(reorg): extract notes/note_type/file_uploads/reports/risk_acceptance [9/10] #14986 — peripheral: notes/note_type + file_uploads + reports + risk_acceptance
  10. refactor(reorg): extract regulations/banner/announcement/development_environment/object [10/10] #14987 — peripheral: regulations + banner + announcement + development_environment + object

Merge #14970 first; each following branch is rebased onto the updated base and merged in turn. PRs 6–10 (draft, head branches on the DefectDojo upstream repo) continue the stack on top of #14974 — full implementation brief is the Phase 10 section in AGENTS.md.

Summary

Reorganizes the Engagement domain into a self-contained dojo/engagement/ package with ui/ and api/ subpackages, matching the dojo/url/ reference and the just-completed dojo/test/ module.

  • Models — move Engagement, Engagement_Presets + admin into dojo/engagement/{models,admin}.py. Cross-module FKs use string references; ENGAGEMENT_STATUS_CHOICES single-sourced + re-exported. Engagement_Survey left in place.
  • Services — extract the engagement copy workflow (clone + product grade recalc + notification) out of the copy_engagement view into an HTTP-free copy_engagement(engagement, user) service so UI and API can share it; view thinned to call it. Adds a unit test (the workflow was previously untested).
  • Forms — move EngForm, DeleteEngagementForm, EngagementPresetsForm, DeleteEngagementPresetsForm, AddEngagementForm, ExistingEngagementForm into dojo/engagement/ui/forms.py.
  • UI filters — move the EngagementDirect*, Engagement*, ProductEngagement(s)* and EngagementTest* filter classes into dojo/engagement/ui/filters.py (base classes like DojoFilter stay in dojo/filters.py).
  • Views/URLs — move the engagement views and URL conf into dojo/engagement/ui/{views,urls}.py; update the dojo/urls.py include and the dojo/asset/urls.py consumer.
  • API — move the engagement serializers into dojo/engagement/api/serializer.py (lazy imports for Note/File/TagList serializers to avoid a cycle), ApiEngagementFilter into dojo/engagement/api/filters.py, EngagementViewSet + EngagementPresetsViewset into dojo/engagement/api/views.py, and the DRF route registration into dojo/engagement/api/urls.py via add_engagement_urls(router). Routes and basenames (engagements/engagement, engagement_presets/engagement_presets) are preserved exactly.
  • Backward-compat re-exports are kept where a symbol is still consumed by code remaining in the monolith (e.g. EngagementSerializer, the externally-used forms); re-exports that would create an import cycle (filters ↔ dojo.filters, viewsets/serializers ↔ dojo.api_v2) are dropped and the consumers point at the new path. No migration change.

@valentijnscholten valentijnscholten changed the title refactor(engagement): extract Engagement models into dojo/engagement/ [Phase 1, 3/5] refactor(engagement): self-contained dojo/engagement/ module (models + services) [3/5] Jun 7, 2026
@valentijnscholten valentijnscholten force-pushed the reorg/engagement-models branch from 619aa3c to 7814217 Compare June 7, 2026 17:58
@valentijnscholten valentijnscholten changed the title refactor(engagement): self-contained dojo/engagement/ module (models + services) [3/5] refactor(engagement): self-contained dojo/engagement/ module [3/5] Jun 7, 2026
@valentijnscholten valentijnscholten force-pushed the reorg/engagement-models branch from 7814217 to 6f8ddfa Compare June 7, 2026 18:54
@github-actions github-actions Bot added the apiv2 label Jun 7, 2026
@valentijnscholten valentijnscholten force-pushed the reorg/engagement-models branch from af767e0 to 517f275 Compare June 7, 2026 19:38
@valentijnscholten valentijnscholten changed the title refactor(engagement): self-contained dojo/engagement/ module [3/5] refactor(engagement): Extract Test models into dojo/test/ module [3/5] Jun 7, 2026
@valentijnscholten valentijnscholten force-pushed the reorg/engagement-models branch from 517f275 to aaefda7 Compare June 7, 2026 21:29
…to dojo/engagement/

Phase 1 of module reorg per AGENTS.md. Move Engagement, Engagement_Presets +
admin registrations into dojo/engagement/{models,admin}.py. Cross-module FKs use
string refs to avoid circular imports; ENGAGEMENT_STATUS_CHOICES single-sourced
with re-export. No migration change.
…py [Phase 2 pilot]

Phase 2 of module reorg per AGENTS.md. Move the engagement copy workflow (copy +
product grade recalc + notification) out of the copy_engagement view into an
HTTP-free copy_engagement(engagement, user) service, so both UI and (future) API
can reuse it. The inline notification carried a TODO asking for exactly this.
View is thinned to call the service. Add a unit test for the service (the workflow
was previously untested). Notification URL uses relative reverse() to match the
codebase convention.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant