Skip to content

fix: resolve frontend timestamp overwrite, and fix test fixtures - #59

Open
irenecancode wants to merge 2 commits into
mainfrom
fix/backend-timezone-fix
Open

irenecancode wants to merge 2 commits into
mainfrom
fix/backend-timezone-fix

Conversation

@irenecancode

Copy link
Copy Markdown
Collaborator

Summary

Wires up the post creation timestamp end-to-end on the feed and post detail pages, fixing two silent display bugs uncovered along the way, adding regression coverage for both, and adding a relative-time UX improvement.

Bug fixes

  • Feed and post detail pages were displaying the wrong timestamp. _normalize_post() in web_views.py was unconditionally overwriting the API's created field with encounter_datetime (the wildlife sighting time, not the post's creation time) — in both the server-rendered templates and the infinite-scroll JSON endpoint. Removed the overwrite so the real created value reaches the templates.
  • The timestamp was actually rendering blank, not just wrong. Django's |date: template filter silently renders "" when given a raw string instead of a datetime object. Since the API client does plain response.json() with no datetime parsing, this had likely been invisible in the feed/detail views for a while. Fixed by parsing created into a proper datetime via parse_datetime() (defensively guarded so it's idempotent regardless of call order).

Test coverage

  • FAKE_POST test fixture now includes a created value distinct from encounter_datetime — previously it didn't include created at all, so the existing suite could neither catch the original bug nor verify the fix.
  • Added assertions on both affected code paths (server-rendered feed context, and the load-more JSON response) pinning that created — not encounter_datetime — is what's returned.

UX enhancement

  • Feed timestamps now show relative time ("now", "an hour ago", "2 days ago", etc.) instead of an absolute date, using Django's built-in humanize.naturaltime filter for the initial page render.
  • The infinite-scroll JS path (formatDate()) was rewritten to match naturaltime's output exactly — verified boundary-for-boundary against Django's filter — so timestamps read consistently regardless of how a post entered the feed.

Test plan

  • python manage.py test siteapps.socialmedia.test_web_views — all 39 tests passing
  • Manually verified relative-time formatting matches between server-rendered and infinite-scroll-loaded posts
  • Manual smoke test of feed + post detail pages in a browser

Follow-up (separate PR)

  • Align USE_TZ/TIME_ZONE settings between WildeBackyardBackend and WildeBackyardWeb (they currently share a database but disagree on timezone handling)
  • Clean up leftover project_restoration scaffold docstrings in WildeBackyardWeb

@irenecancode
irenecancode requested a review from oldtopos July 15, 2026 00:07
@oldtopos
oldtopos force-pushed the fix/backend-timezone-fix branch from e091acd to e5bfbad Compare August 16, 2026 16:47

This branch has not been deployed

No deployments
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.

1 participant