Skip to content

refactor(backend): move various endpoints to modelviewsets - #11617

Merged
SchrodingersGat merged 27 commits into
inventree:masterfrom
matmair:move-to-router
Apr 11, 2026
Merged

SchrodingersGat merged 27 commits into
inventree:masterfrom
matmair:move-to-router

Conversation

@matmair

@matmair matmair commented Mar 27, 2026 •

Copy link
Copy Markdown
Member

This makes it easier to have uniform URL names and behaviors; also adds a bit more testing and cleans up some path docstrings.

Still to figure out:

  • bulk delete only on list endpoints
  • some wired API behaviors are hard to refactor - keep them or use this to clean them up? -> added todo for now

Todo when stable:

  • document how to add API endpoints the correct way

@matmair matmair self-assigned this Mar 27, 2026
@matmair matmair added api Relates to the API refactor labels Mar 27, 2026
@netlify

netlify Bot commented Mar 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 96914db
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/69d9ebbba0564700098ae027
😎 Deploy Preview https://deploy-preview-11617--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 92 (🔴 down 1 from production)
Accessibility: 81 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Mar 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.87234% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.35%. Comparing base (fffc55c) to head (96914db).
⚠️ Report is 374 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #11617   +/-   ##
=======================================
  Coverage   91.34%   91.35%           
=======================================
  Files         966      967    +1     
  Lines       50210    50242   +32     
=======================================
+ Hits        45866    45900   +34     
+ Misses       4344     4342    -2     
Flag Coverage Δ
backend 89.25% <97.87%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 91.69% <ø> (ø)
Backend General 93.41% <100.00%> (+0.06%) ⬆️
Frontend ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matmair matmair added this to the 1.3.0 milestone Mar 30, 2026
@matmair

matmair commented Mar 30, 2026 •

Copy link
Copy Markdown
Member Author

@SchrodingersGat would appreciate a look here. This
a) makes it harder (more explicit) to declare API endpoint that do not follow a uniform style
b) basically replaces the mixin + list + detail view ... url defintion pattern with viewset + urlregistration keeping code fragments together
c) enables us to move url definition patterns into one singe route generator instead of distributed url definitions

As seen this can be done in small steps and is still very similar to current patterns / allows reuse of current view mixins

@SchrodingersGat

Copy link
Copy Markdown
Member

@matmair I think that this is a good move overall. Would we be looking to move a greater portion of our endpoints to this setup? Or just a small number to start with?

@matmair

matmair commented Apr 3, 2026

Copy link
Copy Markdown
Member Author

my goal would be to move all model/object based API endpoint to viewsets and keep view/function based endpoints only for stand-alone actions.

As that would be a large diff and there are small decisions to be taken regularly regarding abnormlaities in the current API I think batching this over a longer time is the way to go

@SchrodingersGat

Copy link
Copy Markdown
Member

@matmair I'd like to get 1.3.0 out soon (as there are some major fixes that people are waiting on) - so I'll bump this to 1.4.0

@SchrodingersGat SchrodingersGat modified the milestones: 1.3.0, 1.4.0 Apr 3, 2026
@matmair
matmair marked this pull request as ready for review April 9, 2026 14:28
@matmair
matmair requested a review from SchrodingersGat as a code owner April 9, 2026 14:28
@matmair
matmair marked this pull request as draft April 9, 2026 14:30
@matmair

matmair commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

one permission todo, then this is ready

@matmair
matmair marked this pull request as ready for review April 9, 2026 14:45
@matmair

matmair commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

@SchrodingersGat this is ready for review and merge. I have identified and documented various inconsistent API details, those are kept for now. My plan would be to do a separate PR to change these (breaking) and discuss details there then to keep this one focused on the pure refactor

@SchrodingersGat

Copy link
Copy Markdown
Member

Nice, this is a great refactor and much cleaner code. Please address the conflict and then I'm happy to merge

@matmair

matmair commented Apr 11, 2026

Copy link
Copy Markdown
Member Author

@SchrodingersGat ready for merge

@SchrodingersGat
SchrodingersGat merged commit 366d4c3 into inventree:master Apr 11, 2026
37 checks passed
@SchrodingersGat
SchrodingersGat deleted the move-to-router branch April 11, 2026 07:37
martonmiklos pushed a commit to martonmiklos/InvenTree that referenced this pull request Jun 30, 2026
…#11617)

* move to router based path building

* fix url names

* fix import

* fix test helper

* fix test

* more test fixes

* fix api response

* remove url patch

* bump api version

* reduce diff

* Fix version tag

* fix schema generation errors

* adjust texts

* fix tests

* add test for notification behavior / readakk

* add todo for wrong endpoint

* rename

* adjust docstring

* fix outstanding permission todo - this pattern should be changed in the API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants