Skip to content

[T3630] muskathlon participants's original photo kept - #440

Open
danpa32 wants to merge 6 commits into
18.0from
T3630-participant-original-photo
Open

danpa32 wants to merge 6 commits into
18.0from
T3630-participant-original-photo

Conversation

@danpa32

@danpa32 danpa32 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

[T3630] Keep the participant's original photo and link it in the new registration messages

Branch T3630-participant-original-photo in compassion-website, based on origin/18.0:

  • 1be124d7 original photo, download links, clear upload error, tests
  • dcd0947e download named after the participant
  • 31f1e4e4 review: keep the uploaded picture itself instead of a second copy
  • af0ba830 merge of the latest 18.0
  • e0eb6dee public photo route: bounded size, no metadata
  • c218b750 merge of the latest 18.0

Problem

When someone registers for a Muskathlon or a trip, the profile picture they upload is only stored resized (500 px before, 1920 px since T3266). The file as uploaded is not kept anywhere, so the events team has to ask participants again for an HD version for print material. The "New Muskathlon registration" e-mail lists the registration details but has no way to get the picture.

While testing, two more issues showed up:

  • Odoo also resizes every stored JPG/PNG attachment to 1920 px (base.image_autoresize_max_px).
  • A picture Odoo cannot read (typically an iPhone HEIC photo) or one above 50 megapixels makes the registration form fail with the generic "An error occurred, the form was not sent": Odoo's image error is a lazy translation that the website form cannot send back to the browser.

Change

website_event_compassion:

  • profile_picture is stored as uploaded: no size cap on the field anymore, and it is written without the attachment auto-resize (image_no_postprocess). Web pages are unaffected: they already request resized versions (/web/image/.../1024x1024, /event/registration/<id>/photo/<size>), the shop line image and the partner image keep their own caps.
  • The "New registration" note posted on the event for its responsible gets a "Download the profile picture" link (trips and all other events). The file downloads as <participant name>.jpg (or .png, from the stored file's type), named when the message is sent.
  • The link goes through /web/login?redirect=...: logged-in staff download directly, logged-out staff log in first (the download alone answers Not Found when logged out).
  • Uploaded pictures are checked before Odoo processes them: unreadable files, pictures above 50 Mpx and pictures Pillow refuses to open at all (decompression bomb, about 180 Mpx) are refused with a message asking for a JPG or PNG file.
  • The upload fields of the registration form and of "My events" only offer JPG and PNG (accept), so iPhones convert HEIC photos to JPEG by themselves.
  • Duplicating a registration keeps its picture and skips the upload checks.
  • The public participant photo (/event/registration/<id>/photo) never gives the stored original: without a size it serves 1920 px at most, as before this change. Resizing also removes the photo's metadata (GPS position, camera…). The pages already ask for smaller sizes.

muskathlon:

  • The "New Muskathlon registration" e-mail gets a "Profile picture: Download" line; the link is passed to the template as a render value.

fr/de/it translations for all new texts.

Pictures uploaded before this change cannot be recovered: only the resized version was ever stored.

Review of the first version

The first version kept a second field, profile_picture_original, beside the capped picture. Following the review, it is gone: one picture, stored as uploaded. This also removes the duplicate copy in the filestore, the stored file name, and the case where a duplicated registration got the capped picture as its "original". No migration is needed: the field never reached 18.0 or stage.

Not changed from the review:

  • The "My events" edit form does run the checks: the form's related image field passes the uploaded picture to the registration's write() untouched. A test now covers it.
  • accept in the form builder (registration_form_snippet.esm.js): Odoo 18's website form editor has no accept option for file fields, so it would need an override of the core template.

Tests

  • website_event_compassion/tests/test_profile_picture_original.py: JPG and PNG pictures kept at 4000 x 3000 and their download named after the participant with the right extension; same through the "My events" edit form; an unreadable (HEIC) file and a decompression-bomb picture are refused; a duplicate keeps its picture; the event note contains the download link; no link without a picture.
  • website_event_compassion/tests/test_public_photo.py: a 4000 x 3000 JPG with GPS and camera metadata comes back from the public route at 1920 x 1440 without metadata; a requested size is still served.
  • muskathlon/tests/test_registration_notification.py: the registration e-mail contains the link; no link without a picture.

11 tests pass.

Manual test: register on a Muskathlon event with a large JPG; the "New Muskathlon registration" e-mail and the event's "New registration" note contain the link, which downloads the full-size picture named after the participant (after login if needed). Uploading a HEIC file shows the JPG/PNG message instead of the generic error.

Deploy

-u website_event_compassion,muskathlon

🤖 Generated with Claude Code

…registration messages

- website_event_compassion: new staff-only field profile_picture_original
  holds the uploaded picture as received (attachment auto-resize skipped),
  refreshed on each new upload; download button on the registration form.
- The "New registration" note to the event responsible and the Muskathlon
  registration e-mail link the original through the login page.
- Unreadable (e.g. HEIC) or oversized pictures are refused with a message
  naming JPG/PNG instead of the website form's generic error; the upload
  fields only offer JPG and PNG.
- fr/de/it translations, tests in both modules.
The original picture is downloaded as "<participant name>.<jpg|png>"
instead of event.registration-<id>-profile_picture_original, from the
e-mail links and from the registration form.

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

This review is AI-generated (Claude Code) and has not been verified line by line.

Is the new field really needed?

Probably not. The existing profile_picture is capped in two places only:

  1. the field-level max_width/max_height (MAX_PROFILE_PICTURE_DIMENSION),
  2. Odoo's attachment auto-resize (base.image_autoresize_max_px), which the PR already bypasses with image_no_postprocess.

Dropping the field-level cap, writing profile_picture under image_no_postprocess in create/write, and pointing the download link at profile_picture would serve full quality with a single binary. Web pages already request resized versions (/web/image/.../1024x1024), so they are unaffected. This would remove profile_picture_original, profile_picture_original_filename, the sudo context method, the risk of the two pictures diverging, and one extra copy of each upload in the filestore. The only trade-off: _check_profile_picture_min_size would read the uncapped picture (a short note is enough).

Other points

  • _check_profile_picture_format does not catch Pillow's DecompressionBombError (not a ValueError/OSError): a ~180 Mpx image still gives the generic form error.
  • "My events" edit form: the upload goes through the wizard's related fields.Image first, so the new validation may never run there. Tests only call create/write directly.
  • copy(): the duplicate gets the already capped picture as its "original", and the new format check ignores SKIP_PROFILE_PICTURE_CHECK.
  • Validation accepts any format Pillow opens while the message and accept say JPG/PNG; accept is missing in the form-builder field definitions (registration_form_snippet.esm.js).
  • muskathlon/data/registration_mail_template.xml: calling the private object.sudo()._get_profile_picture_download_url() from QWeb is fragile; pass the URL via render_values instead. The link also leads non-staff followers to an access error after login.
  • The upload is base64-decoded and parsed 4-5 times per request; decode once.
  • profile_picture_original_filename is stored once, can end up as just .jpg, and does not follow partner renames (would be better computed, or gone if the field is dropped).

@danpa32 danpa32 closed this Nov 4, 2026
Review of #440: profile_picture is no longer resized (field cap and
attachment auto-resize), so the staff download it as uploaded and the
profile_picture_original fields are dropped. The download link is named
after the participant when the message is sent, and is passed to the
Muskathlon mail as a render value. Pictures Pillow refuses to open
(decompression bomb) get the 'too large' message, and a duplicate skips
the upload checks.
@danpa32

danpa32 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Changes are in 31f1e4e (plus a merge of the latest 18.0):

  • Single field: done. profile_picture is no longer capped and is written with image_no_postprocess, so it is kept as uploaded. profile_picture_original and its filename field are removed. The download link points to profile_picture, named after the participant when the message is sent. The pages were already requesting resized versions; the shop line image and the partner image keep their own caps. No migration: the field never reached 18.0 or stage.
  • DecompressionBombError: caught, gives the "too large" message (translated), with a test.
  • "My events" edit form: the check does run there. The wizard's related image field passes the uploaded value to the registration's write() unprocessed. Added a test through event.registration.form.
  • copy(): the duplicate keeps its picture, and the format check now honours SKIP_PROFILE_PICTURE_CHECK (test added).
  • accept in the form builder: not done. Odoo 18's website.form_field_binary template has no accept option, so it would need a core template override. The two forms in our templates keep their accept.
  • Mail template: the URL is now passed through render_values. The link goes to the backend, so it is meant for staff; portal followers would get an access error, as before.
  • Decoding several times / stored filename: mostly gone with the single field. The filename is computed from the participant's name and the stored file's mimetype.

9 tests pass. PR description updated.

@danpa32 danpa32 reopened this Nov 4, 2026
@danpa32
danpa32 requested a review from ecino November 4, 2026 13:58
The picture is now stored as uploaded for the staff. The public photo route served it in full when no size was asked, with the photo's metadata (GPS position...). Without a size it now serves 1920 px at most, as before.
@danpa32

danpa32 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai review

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