Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Image dimensions update management command #1434

Merged
merged 9 commits into from
Nov 8, 2023

Conversation

benzkji
Copy link
Contributor

@benzkji benzkji commented Nov 4, 2023

Description

Basic management command, to insert missing image dimensions.
I've added a test, but can't find instructions on how to setup local tests.

Also, I've only seen conventional commits just now...so...

  • I have opened this pull request against master
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on
    Slack to find a “pr review buddy” who is going to review my pull request.

tests/test_filer_check.py Fixed Show fixed Hide fixed
@benzkji benzkji changed the title first draft: image dimensions update managemenet command image dimensions update managemenet command Nov 4, 2023
@benzkji
Copy link
Contributor Author

benzkji commented Nov 4, 2023

I guess I am doing too much work here. It would probably better to call some helper function of filer? Change a field, call save(), and thus triggering calculation of _width and _height (and possibly other meta fields).

Also, my test fails, probalby because the provided JPG is not a real one?

Copy link
Member

@fsbraun fsbraun left a comment

Choose a reason for hiding this comment

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

@benzkji Two little things (which I might be wrong about).

filer/management/commands/filer_check.py Outdated Show resolved Hide resolved
filer/management/commands/filer_check.py Outdated Show resolved Hide resolved
@fsbraun
Copy link
Member

fsbraun commented Nov 6, 2023

@benzkji I would be fine if you caught the PIL.UnidentifiedImageError, and potentially any FileNotFound error in the management command. They indicate an inconsistent state: corrupted or missing files.

Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (c9872d8) 76.43% compared to head (85cbf62) 76.59%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1434      +/-   ##
==========================================
+ Coverage   76.43%   76.59%   +0.15%     
==========================================
  Files          75       75              
  Lines        3514     3546      +32     
  Branches      562      568       +6     
==========================================
+ Hits         2686     2716      +30     
- Misses        666      667       +1     
- Partials      162      163       +1     
Files Coverage Δ
filer/management/commands/filer_check.py 83.67% <93.75%> (+4.88%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benzkji
Copy link
Contributor Author

benzkji commented Nov 6, 2023

probably last thing: test with SVG, and "corrupt" SVG.

@fsbraun
Copy link
Member

fsbraun commented Nov 7, 2023

@benzkji I think, also a SVG-based test would be great. Here's a way to easily test SVGs:

https://github.com/benzkji/django-filer/blob/6aa899527585d6d352bb0c008cf451791e168a4c/tests/test_validation.py#L26-L30

Copy link
Member

@fsbraun fsbraun left a comment

Choose a reason for hiding this comment

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

Great work, @benzkji ! Thanks so much!

@fsbraun fsbraun changed the title image dimensions update managemenet command feat: Image dimensions update management command Nov 8, 2023
@fsbraun fsbraun merged commit 2e37d58 into django-cms:master Nov 8, 2023
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants