Skip to content

Fix profile picture vanishing after page refresh#158

Open
xenacode-art wants to merge 14 commits intom2b3:testfrom
xenacode-art:fix/profile-pic-url-returns-full-url
Open

Fix profile picture vanishing after page refresh#158
xenacode-art wants to merge 14 commits intom2b3:testfrom
xenacode-art:fix/profile-pic-url-returns-full-url

Conversation

@xenacode-art
Copy link
Copy Markdown

Closes #35

What was happening

Both UserBasicDetails.from_model() and UserDetails.resolve_user() were
returning user.profile_pic_url directly. That's a Django FieldFile
object — when it gets serialised to JSON it becomes the raw storage path
(e.g. profile_images/dev/1_user_abc123.jpg), not an actual URL the
browser can fetch.

So the profile picture appears to work right after upload (the frontend
shows a local preview), but on refresh the frontend requests the URL from
the API, gets an unresolvable path, and the image disappears.

Fix

Return user.profile_pic_url.url instead, which resolves to the correct
S3 or local media URL depending on the storage backend. Falls back to
None for users with no profile picture. Updated the profile_pic_url
type hint in UserBasicDetails from str to Optional[str] to match.

armanalam03 and others added 14 commits December 14, 2025 20:23
Sync Alphatest with Test
Sync Main with AlphaTest
Sync test with alphatest
Sync main with Alphatest
Sync AlphaTest with Test
Sync Main with Alphatest
change MAX_COMMUNITIES_PER_USER to 40
change MAX_COMMUNITIES_PER_USER to 40
Community names containing special characters (e.g. '+', spaces) were
being inserted raw into notification link paths, causing 404s when
users clicked through. Apply urllib.parse.quote(..., safe='') to all
in-app notification links that include the community name in the path.

Fixes m2b3#119
Introduces two new components:

- myapp/services/ai_tasks.py: a Celery shared_task that sends an
  article abstract to a locally running Ollama instance, retrieves
  a 2-3 sentence summary and a JSON array of keywords, and returns
  them as a structured result. The Ollama base URL and model are
  configurable via OLLAMA_BASE_URL and OLLAMA_MODEL settings so no
  external API keys are required.

- articles/ai_api.py: two endpoints wired into the articles router:
    POST /{slug}/ai-summarize  — queues the task, returns task_id
    GET  /ai-task/{task_id}    — polls task state and result

Connection and timeout errors trigger automatic Celery retries so
transient Ollama unavailability does not surface as hard failures.
The schemas were returning user.profile_pic_url directly which is a
FieldFile object, not a string. Django serialises it as the raw storage
path so the frontend gets something like profile_images/dev/abc123.jpg
instead of an actual URL — which is why the picture shows up on upload
(local preview) but disappears on refresh.

Changed both UserBasicDetails and UserDetails to return
user.profile_pic_url.url when set, falling back to None when empty.
Updated the type hint to Optional[str] to match.

Fixes m2b3#35
@xenacode-art xenacode-art changed the base branch from main to test March 22, 2026 20:38
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.

Unable to save the profile image.

2 participants