Your details → Fetch my Gravatar again: a failure is shown as a success message #425

Closed
opened 2026-10-01 10:46:36 +00:00 by tiagoagueda · 0 comments
Owner

Found on 2026-09-29 in a read-only review of postulo at 95348908d, comparing the two places that report a Gravatar fetch.

Checked again on 2026-10-01 against main at 0a5cad587: still present.

GravatarRefreshView reports every outcome of avatars.fetch_gravatar with messages.success, including "Gravatar could not be reached just now" and "Gravatar has no picture for your address". ProfileView._after_saving reports the same two outcomes, with the same strings, as a warning and as information. The same failure is therefore drawn green from one button and amber from the other.

  • Where: accounts/views.py:236-243, GravatarRefreshView.post; accounts/views.py:191-203, ProfileView._after_saving; templates/partials/messages.html, which picks the alert variant from message.level_tag.
  • What happens: Gravatar is unreachable and the person presses "Fetch my Gravatar again". The redirect to Your details shows "Gravatar could not be reached just now. Try again later." in a success alert.
  • Why it matters: the colour tells the person the fetch worked while the words say it did not, and the two copies of the outcome-to-message table have already drifted in level; the next string change will have to be made twice.
  • Fix: move the mapping into one helper, for instance report_gravatar(request, outcome) next to avatars.fetch_gravatar, returning success for found, info for none and warning for error, and call it from both views.

Done when

  • A test in tests/test_avatars.py makes the fetch fail, posts to accounts:avatar_refresh, and finds the message at messages.WARNING, not messages.SUCCESS.
Found on 2026-09-29 in a read-only review of postulo at 95348908d, comparing the two places that report a Gravatar fetch. Checked again on 2026-10-01 against `main` at `0a5cad587`: still present. `GravatarRefreshView` reports every outcome of `avatars.fetch_gravatar` with `messages.success`, including "Gravatar could not be reached just now" and "Gravatar has no picture for your address". `ProfileView._after_saving` reports the same two outcomes, with the same strings, as a warning and as information. The same failure is therefore drawn green from one button and amber from the other. - **Where:** `accounts/views.py:236-243`, `GravatarRefreshView.post`; `accounts/views.py:191-203`, `ProfileView._after_saving`; `templates/partials/messages.html`, which picks the alert variant from `message.level_tag`. - **What happens:** Gravatar is unreachable and the person presses "Fetch my Gravatar again". The redirect to Your details shows "Gravatar could not be reached just now. Try again later." in a success alert. - **Why it matters:** the colour tells the person the fetch worked while the words say it did not, and the two copies of the outcome-to-message table have already drifted in level; the next string change will have to be made twice. - **Fix:** move the mapping into one helper, for instance `report_gravatar(request, outcome)` next to `avatars.fetch_gravatar`, returning success for `found`, info for `none` and warning for `error`, and call it from both views. ## Done when - A test in `tests/test_avatars.py` makes the fetch fail, posts to `accounts:avatar_refresh`, and finds the message at `messages.WARNING`, not `messages.SUCCESS`.
tiagoagueda added this to the 0.6.0 milestone 2026-10-01 10:46:36 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Postulo/postulo#425
No description provided.