Skip to content

T3266 implement size check muskathlon - #348

Open
loris-fab wants to merge 5 commits into
18.0from
T3266-Implement-size-check-muskathlon
Open

T3266 implement size check muskathlon#348
loris-fab wants to merge 5 commits into
18.0from
T3266-Implement-size-check-muskathlon

Conversation

@loris-fab

Copy link
Copy Markdown

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.py on the event.registration model:

  • Added _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 both create() and write(), triggered whenever profile_picture is part of the submitted values.
  • The check runs on the raw uploaded base64 value, before Odoo's Image field itself resizes it this ordering matters, since the field previously capped storage at max_width=500, max_height=500, which would have made the 800×1200 check always fail if run afterward.
  • Raised the field's own max_width/max_height from 500 to 1200 (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 dimension
    depending on the upload's orientation (portrait vs. landscape).

Misc

  • This only affects picture uploads/edits going forward. Registrations already in the database keep their existing (possibly low-resolution) picture there's no retroactive fix or migration, since the original higher-resolution bytes were already discarded at upload time.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread website_event_compassion/models/event_registration.py Outdated
Comment thread website_event_compassion/models/event_registration.py Outdated
Comment thread website_event_compassion/models/event_registration.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.Image processing.
  • Raised the stored profile_picture image 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.

Comment thread website_event_compassion/models/event_registration.py Outdated
Comment thread website_event_compassion/models/event_registration.py
@greptile-apps

greptile-apps Bot commented Jul 20, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Safe to merge with minimal risk.

The changed validation is narrow and runs only when profile_picture is submitted. Empty and invalid image payloads are left to the existing Odoo image handling. The remaining changed files are formatting-only.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the profile picture size runtime harness to validate import and sizing behavior using minimal Odoo stubs.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
website_event_compassion/models/event_registration.py Adds pre-resize profile picture dimension validation on create/write and raises the stored image cap to support the accepted resolution.
crowdfunding_compassion/templates/crowdfunding_components.xml Converts an empty replacement header to self-closing XML with no behavioral change.
my_compassion/README.rst Normalizes README list indentation and wrapping without changing module configuration guidance.
my_compassion/static/description/index.html Updates generated HTML description wrapping to match the README formatting changes.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant Form as Event registration form
participant Model as event.registration
participant PIL as PIL image reader
participant Odoo as Odoo Image field

User->>Form: Upload profile_picture
Form->>Model: create/write(vals)
alt profile_picture present
    Model->>PIL: Decode base64 and read dimensions
    PIL-->>Model: width, height
    alt "short side < 800 or long side < 1200"
        Model-->>Form: ValidationError
    else dimensions pass
        Model->>Odoo: super().create/write(vals)
        Odoo-->>Model: Store image with 1200x1200 cap
    end
else no profile_picture update
    Model->>Odoo: super().create/write(vals)
end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant Form as Event registration form
participant Model as event.registration
participant PIL as PIL image reader
participant Odoo as Odoo Image field

User->>Form: Upload profile_picture
Form->>Model: create/write(vals)
alt profile_picture present
    Model->>PIL: Decode base64 and read dimensions
    PIL-->>Model: width, height
    alt "short side < 800 or long side < 1200"
        Model-->>Form: ValidationError
    else dimensions pass
        Model->>Odoo: super().create/write(vals)
        Odoo-->>Model: Store image with 1200x1200 cap
    end
else no profile_picture update
    Model->>Odoo: super().create/write(vals)
end
Loading

Reviews (5): Last reviewed commit: "style: update layout header xpath struct..." | Re-trigger Greptile

Comment thread website_event_compassion/models/event_registration.py
@loris-fab
loris-fab force-pushed the T3266-Implement-size-check-muskathlon branch from 356a2f0 to 4914dab Compare July 20, 2026 15:39
@loris-fab

Copy link
Copy Markdown
Author

Thanks for the review, Ema, you're the best!

@ecino ecino 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.

Instead of overriding create and write methods to check your field you can simply use the method decorator @constrains

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.

3 participants