Skip to content

fix: pre-select weight units from user profile preference - #2439

Open
k-charansai wants to merge 1 commit into
wger-project:masterfrom
k-charansai:fix/pre-select-weight-units
Open

fix: pre-select weight units from user profile preference#2439
k-charansai wants to merge 1 commit into
wger-project:masterfrom
k-charansai:fix/pre-select-weight-units

Conversation

@k-charansai

Copy link
Copy Markdown

Fixes #2205

Summary

When creating SlotEntry or WorkoutLog via the API without an explicit weight_unit, the default was always hardcoded to KG. This change reads the user's profile weight_unit preference ('kg' or 'lb') and uses it as the default.

Changes

  • wger/manager/api/views.py: Added perform_create to SlotEntryViewSet and updated WorkoutLogViewSet.perform_create to default weight_unit from user profile preference.
  • wger/manager/tests/test_api_weight_unit_default.py: Added unit tests covering KG/LB defaults and explicit unit overrides.

Testing

python manage.py test wger.manager.tests.test_api_weight_unit_default

When creating SlotEntry or WorkoutLog via the API without an explicit weight_unit, the default was always hardcoded to KG (id=1). This change reads the user's profile weight_unit preference and uses it as the default, so users who prefer lbs get lbs pre-selected.

Fixes wger-project#2205
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.

Pre-select weight units

1 participant