From d9a2af7168c9e1edab90e8173da95ea4c186dd9b Mon Sep 17 00:00:00 2001 From: Sicherhaven Date: Wed, 22 Apr 2026 00:32:00 +0530 Subject: [PATCH] fix(reviews): expose profile_photo in /api/reviews/list payload _serialize_review() was not returning the reviewer's profile_picture URL, so the consumer app had no field to key off and always rendered DiceBear cartoons for every reviewer. - Resolves r.reviewer.profile_picture.url when non-empty - Treats default.png placeholder as no-photo (returns empty string) - Defensive try/except around FK dereference, same pattern as user.py Paired with mvnew consumer v1.7.8 which consumes the new field. Co-Authored-By: Claude Opus 4.7 --- CHANGELOG.md | 10 ++++++++++ mobile_api/views/reviews.py | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b758fe..7bdfc57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), version --- +## [1.14.1] — 2026-04-22 + +### Fixed +- **`_serialize_review()` now returns `profile_photo`** (`mobile_api/views/reviews.py`) — `/api/reviews/list` payload was missing the reviewer's photo URL, so the consumer app had no choice but to render DiceBear placeholders for every reviewer regardless of whether they had uploaded a real profile picture + - Resolves `r.reviewer.profile_picture.url` when the field is non-empty and the file name is not `default.png` (the model's placeholder default); returns empty string otherwise so the frontend can fall back cleanly to DiceBear + - Mirrors the existing pattern in `mobile_api/views/user.py` (`LoginView`, `StatusView`, `UpdateProfileView`) — same defensive try/except around FK dereference + - Pure serializer change — no migration, no URL change, no permission change; `gunicorn kill -HUP 1` picks it up + +--- + ## [1.14.0] — 2026-04-21 ### Added diff --git a/mobile_api/views/reviews.py b/mobile_api/views/reviews.py index 02200a8..6cf7b2a 100644 --- a/mobile_api/views/reviews.py +++ b/mobile_api/views/reviews.py @@ -29,11 +29,20 @@ def _serialize_review(r, user_interactions=None): uname = r.reviewer.username except Exception: uname = '' + try: + pic = r.reviewer.profile_picture + if pic and pic.name and 'default.png' not in pic.name: + profile_photo = pic.url + else: + profile_photo = '' + except Exception: + profile_photo = '' return { 'id': r.id, 'event_id': r.event_id, 'username': uname, 'display_name': display, + 'profile_photo': profile_photo, 'rating': r.rating, 'comment': r.review_text, 'status': _STATUS_TO_JSON.get(r.status, r.status),