Skip to content

refactor(product_type): Extra ProductType models into dojo/product_type/ module [1/10]#14970

Draft
valentijnscholten wants to merge 9 commits into
devfrom
reorg/product_type-models
Draft

refactor(product_type): Extra ProductType models into dojo/product_type/ module [1/10]#14970
valentijnscholten wants to merge 9 commits into
devfrom
reorg/product_type-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 ◀ this PR
  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
  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

Fully reorganizes the Product Type domain into a self-contained dojo/product_type/ module — the first complete worked example across all layers.

  • Models: Product_Type + admin moved into dojo/product_type/{models,admin}.py; backward-compat re-export in dojo/models.py. No migration change.
  • UI: forms → ui/forms.py (re-exported from dojo/forms.py); ProductTypeFilterui/filters.py (keeps DojoFilter base; no dojo/filters.py re-export needed since its only consumer is the product_type view — avoids a circular import); views → ui/views.py, dojo/organization/urls.py updated.
  • API: ProductTypeSerializerapi/serializer.py (re-exported, still used by ReportGenerateSerializer); ProductTypeViewSetapi/views.py; api/urls.py adds add_product_type_urls() preserving route product_types + basename product_type.
  • Services: none — product_type views are pure CRUD (same as the url/location reference modules).
  • Docs: fold the reorg conventions (string FK refs, ruff noqa, re-export placement, load-bearing imports) into AGENTS.md.

Backward-compat re-exports keep all existing consumers working unchanged.

…type/

Phase 1 of module reorg per AGENTS.md. Move Product_Type class + admin
registration into dojo/product_type/{models,admin}.py with backward-compat
re-export in dojo/models.py. No migration change (app_label unchanged).
…/ui/ [Phase 3,4]

Phase 3+4 of module reorg per AGENTS.md. Move Product_TypeForm,
Delete_Product_TypeForm, Add_Product_Type_AuthorizedUsersForm into ui/forms.py
(re-export from dojo/forms.py) and ProductTypeFilter into ui/filters.py. The filter
keeps its DojoFilter base; its only consumer is the product_type view, so no
dojo/filters.py re-export is kept (matches the url module) — avoids the
extracted-filter<->dojo.filters circular import.
… [Phase 5]

Phase 5 of module reorg per AGENTS.md. Move dojo/product_type/views.py to
dojo/product_type/ui/views.py and update its two importers (dojo/organization/urls.py
and the counts unit test). product_type has no urls.py (routes live in
dojo/organization/urls.py), so only the views move.
… [Phase 6,8,9]

Phase 6/8/9 of module reorg per AGENTS.md (Phase 7 N/A - no product_type API filter).
Move ProductTypeSerializer into api/serializer.py (re-exported from api_v2/serializers.py,
still used by ReportGenerateSerializer) and ProductTypeViewSet into api/views.py. Add
api/urls.py with add_product_type_urls() preserving route 'product_types' + basename
'product_type'; wire it into dojo/urls.py. Viewset re-export omitted (would cycle
api_v2.views<->product_type.api.views; only consumer was a test, now imports new path).
Update AGENTS.md with conventions learned doing the Phase 1 model extractions:
string FK refs to break circular imports, ruff noqa conventions (PLC0415/E402/F401),
consolidated re-export placement, single-sourced constants, load-bearing side-effect
imports, and corrected docker-based verify commands (manage.py shell, run-unittest.sh).
@valentijnscholten valentijnscholten changed the title refactor(product_type): extract Product_Type model into dojo/product_type/ [Phase 1, 1/5] refactor(product_type): self-contained dojo/product_type/ module — full reorg [1/5] Jun 7, 2026
@valentijnscholten valentijnscholten changed the title refactor(product_type): self-contained dojo/product_type/ module — full reorg [1/5] refactor(product_type): self-contained dojo/product_type/ module [1/5] Jun 7, 2026
Conditional services phase; keep filter base class + drop re-export when sole
consumer is the module's own view (circular-import fix); per-symbol re-export
decisions by actual consumers (incl. multi-line imports); preserve DRF route+basename;
run real tests after dropping a re-export.
@valentijnscholten valentijnscholten changed the title refactor(product_type): self-contained dojo/product_type/ module [1/5] refactor(product_type): Extra ProductType models into dojo/product_type/ module [1/5] Jun 7, 2026
Self-contained brief for finishing the reorg: 5 new draft PRs (#6-10)
stacked on top of the finding PR, plus CWE+BurpRawRequestResponse folded
into the existing finding module PR. Bundles, line ranges, stack/cascade
mechanics, and module-specific gotchas. Marks the 5 core modules Complete.
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