Fix profile picture vanishing after page refresh#158
Open
xenacode-art wants to merge 14 commits intom2b3:testfrom
Open
Fix profile picture vanishing after page refresh#158xenacode-art wants to merge 14 commits intom2b3:testfrom
xenacode-art wants to merge 14 commits intom2b3:testfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #35
What was happening
Both
UserBasicDetails.from_model()andUserDetails.resolve_user()werereturning
user.profile_pic_urldirectly. That's a DjangoFieldFileobject — 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 thebrowser 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.urlinstead, which resolves to the correctS3 or local media URL depending on the storage backend. Falls back to
Nonefor users with no profile picture. Updated theprofile_pic_urltype hint in
UserBasicDetailsfromstrtoOptional[str]to match.