Skip to content

[refactor] Attachment images - #11961

Merged
SchrodingersGat merged 22 commits into
inventree:masterfrom
SchrodingersGat:attachment-images
May 22, 2026
Merged

SchrodingersGat merged 22 commits into
inventree:masterfrom
SchrodingersGat:attachment-images

Conversation

@SchrodingersGat

@SchrodingersGat SchrodingersGat commented May 18, 2026 •

Copy link
Copy Markdown
Member

This PR adds / refactors some functionality related to attachments

References

Changes

  • Adds "thumbnail" for attachments which are images
  • Display thumbnail in attachment table
  • Prevent upload of files above a user-configurable size
  • Data migration for existing uploaded attachments

Rationale

This forms the first part of a re-think of how we might approach generic images against any model instance - see #10484

However, none of that will be implemented here - this is a low-scope change to allow discrimination of attachments which are also images, and display them as such in the UI

Tasks

  • Offload thumbnail generation to the background worker
  • Database migration unit tests
  • Demo dataset migration
  • Unit tests for new features

Future Work (Potentially, TBD)

@netlify

netlify Bot commented May 18, 2026 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 427a1cd
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a1012be2a7e850008ac138a
😎 Deploy Preview https://deploy-preview-11961--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: 96 (🟢 up 4 from production)
Accessibility: 81 (🔴 down 1 from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

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

@SchrodingersGat SchrodingersGat added api Relates to the API refactor migration Data or schema migrations User Interface Related to the frontend / User Interface full-run Always do a full QC CI run labels May 18, 2026
@SchrodingersGat SchrodingersGat added this to the 1.4.0 milestone May 18, 2026
@codecov

codecov Bot commented May 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.74611% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.23%. Comparing base (74d9ab6) to head (427a1cd).
⚠️ Report is 391 commits behind head on master.

❌ Your patch status has failed because the patch coverage (92.70%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11961      +/-   ##
==========================================
- Coverage   91.37%   91.23%   -0.14%     
==========================================
  Files         976      971       -5     
  Lines       51733    51103     -630     
==========================================
- Hits        47269    46626     -643     
- Misses       4464     4477      +13     
Flag Coverage Δ
backend 90.27% <89.63%> (+1.02%) ⬆️
migrations 40.64% <45.07%> (-0.87%) ⬇️

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

Components Coverage Δ
Backend Apps 91.49% <ø> (-0.17%) ⬇️
Backend General 93.37% <92.70%> (-0.12%) ⬇️
Frontend ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SchrodingersGat
SchrodingersGat requested a review from matmair May 18, 2026 13:28

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall; if we want to change attachments meaningfully in 1.4.0 I would have some larger points worth adressing

Comment thread src/backend/InvenTree/common/models.py Resolved

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great improvement!

@SchrodingersGat
SchrodingersGat merged commit 27ca083 into inventree:master May 22, 2026
59 of 62 checks passed
@SchrodingersGat
SchrodingersGat deleted the attachment-images branch May 22, 2026 13:37
johnluetke pushed a commit to johnluetke/InvenTree that referenced this pull request May 22, 2026
* Add new Attachment model fields:

- is_image
- thumbnail

* Cache if the attachment is an image

* Add new setting for controlling max upload size

* Validate uploaded attachment file

* Add tqdm for progress bars

* Refactor migrations

- Don't need is_image field
- Can introspect from the thumbnail

* Data migration for existing attachments

* Bump API version

* Update tests and validators

* Add "is_image" field to the Attachment model

* Offload to background task

* Implement unit tests

* Docs

* Add unit test for data migration

* Additional unit test

* Omit migration tests from code coverage

* Additional unit tests
martonmiklos pushed a commit to martonmiklos/InvenTree that referenced this pull request Jun 30, 2026
* Add new Attachment model fields:

- is_image
- thumbnail

* Cache if the attachment is an image

* Add new setting for controlling max upload size

* Validate uploaded attachment file

* Add tqdm for progress bars

* Refactor migrations

- Don't need is_image field
- Can introspect from the thumbnail

* Data migration for existing attachments

* Bump API version

* Update tests and validators

* Add "is_image" field to the Attachment model

* Offload to background task

* Implement unit tests

* Docs

* Add unit test for data migration

* Additional unit test

* Omit migration tests from code coverage

* Additional unit tests
@Reza98Sh

Reza98Sh commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Hi
@SchrodingersGat
does this mean you want to use attachments for multiple images, making this PR obsolete?#10484

@SchrodingersGat

Copy link
Copy Markdown
Member Author

Hi @Reza98Sh not sure which way we will go with this. It may be simpler to have a single table (attachments) which also supports images natively. It also allows us to solve #11647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API full-run Always do a full QC CI run migration Data or schema migrations refactor User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] Move attachments and images to a generic files model

3 participants