feat(core): store timezone information per user (#2472) - #2482
Open
pankaj-basnet wants to merge 19 commits into
Open
feat(core): store timezone information per user (#2472)#2482pankaj-basnet wants to merge 19 commits into
pankaj-basnet wants to merge 19 commits into
Conversation
- Replaced date, time_start, and time_end fields with datetime_start and datetime_end - Updated logging logic to map workouts crossing midnight correctly - Adjusted statistics and trophies calculations to use local timezones - Added data migration to preserve legacy workout dates - Fixed test suites to support multi-day sessions
…n-datetime # Conflicts: # wger/core/tests/test_user.py # wger/gym/helpers.py # wger/manager/tests/test_workout_session.py
A log can be pinned to a session of another day through the API. Without the filter the data migration would move such a session to the day of its logs, silently shifting streaks and date-based trophies
- add TimezoneMiddleware to activate user timezone per request - expose timezone field in UserProfileSerializer - update WorkoutSession.local_day to use user timezone
Member
|
you never rest, do you? 😄 |
Contributor
Author
wger projects repo's are a perfect fit for me 🙌 . i have not done any other project other than django, flutter . now mcp repo is awesome bonus for me 💪🏽 |
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.
This PR adds support for storing IANA timezone names on a user's profile and dynamically activating the user's local timezone for incoming requests. This ensures the user's actual local calendar day rather than the server's global
TIME_ZONEsetting.Proposed Changes
UserProfileModel (wger/core/models/profile.py):timezoneCharField(defaults tosettings.TIME_ZONE).validate_timezonevalidator utilizing Python standard libraryzoneinfo..zone_infoproperty helper onUserProfile.wger/core/migrations/):wger/core/middleware.py&settings_global.py):TimezoneMiddleware.wger/core/api/serializers.py):timezoneonUserProfileSerializer.wger/manager/models/session.py):WorkoutSession.local_day.📋 Design Decision Log
CharFieldstoring standard IANA name string (e.g."Europe/Berlin").settings.TIME_ZONEat creation time.UserProfileSerializer).Related Issue(s)
Closes #2472
Please check that the PR fulfills these requirements
ruff format && isort .)changes etc.), write a small writeup in
CHANGELOG.md