T3266 implement size check muskathlon - #348
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a minimum resolution check for profile pictures in event registrations to ensure high-quality printing on fundraising materials. It increases the profile_picture field's maximum dimensions to 1200px and adds validation during record creation and updates. The review feedback suggests updating the docstring to remove outdated resolution references, catching TypeError during image decoding for improved robustness, and clarifying the validation error message to prevent confusion regarding portrait and landscape orientations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR adds server-side validation to enforce a minimum profile-picture resolution for event registrations, ensuring uploaded images remain suitable for printed fundraising materials after storage/resizing within the Odoo event.registration model.
Changes:
- Added a Pillow-based size validation that checks the raw uploaded profile picture before Odoo’s
fields.Imageprocessing. - Raised the stored
profile_pictureimage cap from 500×500 to 1200×1200 so compliant images aren’t immediately downscaled below the intended quality threshold.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…be printed on fundraising material.
…low the printable minimum
…me doctring modification
356a2f0 to
4914dab
Compare
|
Thanks for the review, Ema, you're the best! |
ecino
left a comment
There was a problem hiding this comment.
Instead of overriding create and write methods to check your field you can simply use the method decorator @constrains
Goal
Some Muskathlon/event participants were uploading very small profile pictures, which then looked blurry or pixelated once printed on fundraising material (flyers, posters,
etc.). This resolution introduces a minimum resolution requirement on the event registration's profile picture so it's guaranteed to look good once printed.
Technical aspect
Both commits touch
website_event_compassion/models/event_registration.pyon theevent.registrationmodel:_check_profile_picture_min_size(), a static validation method using PIL to read the uploaded image's dimensions and reject it (ValidationError) if the short side is below 800px or the long side is below 1200px, in either portrait or landscape orientation. Wired into bothcreate()andwrite(), triggered wheneverprofile_pictureis part of the submitted values.Imagefield itself resizes it this ordering matters, since the field previously capped storage atmax_width=500, max_height=500, which would have made the 800×1200 check always fail if run afterward.max_width/max_heightfrom500to1200(both dimensions, symmetrically) so the resolution just validated by the check is actually preserved in storage instead of being immediately downscaled back below the minimum. A symmetric 1200×1200 cap was required specifically to avoid crushing either dimensiondepending on the upload's orientation (portrait vs. landscape).
Misc