Self hosted FLOSS fitness/workout, nutrition and weight tracker
Formatting
Roland Geider1de5898364b0
diff --git a/wger/core/account_adapter.py b/wger/core/account_adapter.pyindex 91fcb6f14..1ed67860f 100644--- a/wger/core/account_adapter.py+++ b/wger/core/account_adapter.py@@ -72,9 +72,7 @@ class WgerAccountAdapter(DefaultAccountAdapter):return Noneprofile = (- UserProfile.objects.filter(user=user)- .select_related('notification_language')- .first()+ UserProfile.objects.filter(user=user).select_related('notification_language').first())return profile.notification_language.short_name if profile else Nonediff --git a/wger/core/migrations/0025_remove_unused_fields_in_userprofile.py b/wger/core/migrations/0025_remove_unused_fields_in_userprofile.pyindex 05d51ed96..d6f6a1ed5 100644--- a/wger/core/migrations/0025_remove_unused_fields_in_userprofile.py+++ b/wger/core/migrations/0025_remove_unused_fields_in_userprofile.py@@ -4,7 +4,6 @@ from django.db import migrationsclass Migration(migrations.Migration):-dependencies = [('core', '0024_backfill_emailaddress'),]diff --git a/wger/core/migrations/0026_alter_userprofile_birthdate_alter_userprofile_height.py b/wger/core/migrations/0026_alter_userprofile_birthdate_alter_userprofile_height.pyindex 587a93ab3..0cad07ab0 100644--- a/wger/core/migrations/0026_alter_userprofile_birthdate_alter_userprofile_height.py+++ b/wger/core/migrations/0026_alter_userprofile_birthdate_alter_userprofile_height.py@@ -6,7 +6,6 @@ from django.db import migrations, modelsclass Migration(migrations.Migration):-dependencies = [('core', '0025_remove_unused_fields_in_userprofile'),]@@ -15,11 +14,24 @@ class Migration(migrations.Migration):migrations.AlterField(model_name='userprofile',name='birthdate',- field=models.DateField(blank=True, null=True, validators=[wger.core.models.profile.birthdate_validator], verbose_name='Date of Birth',),+ field=models.DateField(+ blank=True,+ null=True,+ validators=[wger.core.models.profile.birthdate_validator],+ verbose_name='Date of Birth',+ ),),migrations.AlterField(model_name='userprofile',name='height',- field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(140), django.core.validators.MaxValueValidator(230)], verbose_name='Height (cm)',),+ field=models.IntegerField(+ blank=True,+ null=True,+ validators=[+ django.core.validators.MinValueValidator(140),+ django.core.validators.MaxValueValidator(230),+ ],+ verbose_name='Height (cm)',+ ),),]diff --git a/wger/core/tests/test_app_auth_handoff.py b/wger/core/tests/test_app_auth_handoff.pyindex 09280ba7d..53b097f6d 100644--- a/wger/core/tests/test_app_auth_handoff.py+++ b/wger/core/tests/test_app_auth_handoff.py@@ -86,4 +86,3 @@ class AppAuthHandoffTestCase(WgerTestCase):self.assertEqual(parsed.query, '')self.assertTrue(parsed.fragment.startswith('token='))self.assertGreater(len(parsed.fragment), len('token='))-diff --git a/wger/core/views/user.py b/wger/core/views/user.pyindex 3e56ba525..868ed8f8d 100644--- a/wger/core/views/user.py+++ b/wger/core/views/user.py@@ -107,16 +107,16 @@ from wger.utils.api_token import (count_active_jwt_refresh_tokens,create_token,)+from wger.utils.generic_views import (+ WgerFormMixin,+ WgerMultiplePermissionRequiredMixin,+)from wger.utils.headless_long_lived import (list_long_lived_sessions,mint_long_lived_refresh_token,revoke_all_long_lived_sessions,revoke_long_lived_session,)-from wger.utils.generic_views import (- WgerFormMixin,- WgerMultiplePermissionRequiredMixin,-)from wger.weight.models import WeightEntry@@ -177,9 +177,7 @@ def delete(request, user_pk=None):if request.method == 'POST' and form.is_valid():user.delete()- messages.success(- request, _('Account "{0}" was successfully deleted').format(user.username)- )+ messages.success(request, _('Account "{0}" was successfully deleted').format(user.username))if not user_pk:django_logout(request)@@ -292,9 +290,7 @@ class WgerSignupView(AllauthSignupView):return HttpResponseRedirect(reverse('software:features'))if request.user.is_authenticated and request.user.userprofile.is_temporary:# Skip RedirectAuthenticatedUserMixin's "already logged in" redirect- return super(RedirectAuthenticatedUserMixin, self).dispatch(- request, *args, **kwargs- )+ return super(RedirectAuthenticatedUserMixin, self).dispatch(request, *args, **kwargs)return super().dispatch(request, *args, **kwargs)@@ -541,9 +537,7 @@ def api_key(request):context['active_jwt_sessions'] = count_active_jwt_refresh_tokens(request.user)context['new_refresh_token'] = request.session.pop(_NEW_REFRESH_TOKEN_SESSION_KEY, None)context['long_lived_sessions'] = list_long_lived_sessions(request.user)- context['refresh_token_lifetime_days'] = (- settings.HEADLESS_JWT_REFRESH_TOKEN_EXPIRES_IN // 86400- )+ context['refresh_token_lifetime_days'] = settings.HEADLESS_JWT_REFRESH_TOKEN_EXPIRES_IN // 86400return render(request, 'user/api_key.html', context)@@ -569,9 +563,7 @@ def app_auth_handoff(request):)state = request.GET.get('state', '')- if state and (- len(state) > _APP_AUTH_STATE_MAX_LEN or not _APP_AUTH_STATE_ALLOWED.match(state)- ):+ if state and (len(state) > _APP_AUTH_STATE_MAX_LEN or not _APP_AUTH_STATE_ALLOWED.match(state)):state = ''# Token goes in the URL fragment, not the query string, so it never landsdiff --git a/wger/manager/models/session.py b/wger/manager/models/session.pyindex 1899168e8..6d74cd361 100644--- a/wger/manager/models/session.py+++ b/wger/manager/models/session.py@@ -28,7 +28,6 @@ from django.utils.translation import gettext_lazy as _from wger.utils.uuid import uuid7-class WorkoutSession(models.Model):"""Model for a workout sessiondiff --git a/wger/nutrition/migrations/0037_powersync_synced_ingredient_tables.py b/wger/nutrition/migrations/0037_powersync_synced_ingredient_tables.pyindex 9d264fa9a..1c3a13040 100644--- a/wger/nutrition/migrations/0037_powersync_synced_ingredient_tables.py+++ b/wger/nutrition/migrations/0037_powersync_synced_ingredient_tables.py@@ -50,7 +50,6 @@ be mirrored here, in the SAME migration that alters the source model:"""-SQL = [# Shadow table: structure cloned incl. PK (= replica identity for logical# replication). EXCLUDING IDENTITY so we can insert the explicit ids copied@@ -60,7 +59,6 @@ SQL = [LIKE nutrition_ingredient INCLUDING ALL EXCLUDING IDENTITY);""",-# Copy an ingredient into the shadow set"""CREATE OR REPLACE FUNCTION powersync_ensure_ingredient_synced(ing_id bigint)@@ -70,7 +68,6 @@ SQL = [ON CONFLICT (id) DO NOTHING;$$;""",-# On every log and meal item, pull its ingredient into the shadow set."""CREATE OR REPLACE FUNCTION powersync_sync_ingredient_from_item()@@ -90,7 +87,6 @@ SQL = [AFTER INSERT OR UPDATE OF ingredient_id ON nutrition_mealitemFOR EACH ROW EXECUTE FUNCTION powersync_sync_ingredient_from_item();""",-# Keep already-synced ingredient rows fresh when the source changes."""CREATE OR REPLACE FUNCTION powersync_propagate_ingredient()@@ -109,7 +105,6 @@ SQL = [AFTER UPDATE ON nutrition_ingredientFOR EACH ROW EXECUTE FUNCTION powersync_propagate_ingredient();""",-# Backfill everything already referenced by a log or meal item."""SELECT powersync_ensure_ingredient_synced(id) FROM (@@ -121,13 +116,13 @@ SQL = []REVERSE_SQL = [- "DROP TRIGGER IF EXISTS powersync_propagate ON nutrition_ingredient;",- "DROP TRIGGER IF EXISTS powersync_sync_ingredient ON nutrition_mealitem;",- "DROP TRIGGER IF EXISTS powersync_sync_ingredient ON nutrition_logitem;",- "DROP FUNCTION IF EXISTS powersync_propagate_ingredient();",- "DROP FUNCTION IF EXISTS powersync_sync_ingredient_from_item();",- "DROP FUNCTION IF EXISTS powersync_ensure_ingredient_synced(bigint);",- "DROP TABLE IF EXISTS nutrition_synced_ingredient;",+ 'DROP TRIGGER IF EXISTS powersync_propagate ON nutrition_ingredient;',+ 'DROP TRIGGER IF EXISTS powersync_sync_ingredient ON nutrition_mealitem;',+ 'DROP TRIGGER IF EXISTS powersync_sync_ingredient ON nutrition_logitem;',+ 'DROP FUNCTION IF EXISTS powersync_propagate_ingredient();',+ 'DROP FUNCTION IF EXISTS powersync_sync_ingredient_from_item();',+ 'DROP FUNCTION IF EXISTS powersync_ensure_ingredient_synced(bigint);',+ 'DROP TABLE IF EXISTS nutrition_synced_ingredient;',]diff --git a/wger/urls.py b/wger/urls.pyindex 1099c3dbd..81aabd688 100644--- a/wger/urls.py+++ b/wger/urls.py@@ -297,11 +297,9 @@ urlpatterns = i18n_patterns(urlpatterns += [path('i18n/', include('django.conf.urls.i18n')),path('robots.txt', TextTemplateView.as_view(template_name='robots.txt'), name='robots'),-# allauth account pages are mounted without a language prefix: the OAuth# callback's redirect_uri has to be stablepath('account/', include('allauth.urls')),-# REST auth API consumed by the Flutter app.path('allauth/', include('allauth.headless.urls')),# APIdiff --git a/wger/utils/headless_long_lived.py b/wger/utils/headless_long_lived.pyindex 989d671ef..d3a45a2b7 100644--- a/wger/utils/headless_long_lived.py+++ b/wger/utils/headless_long_lived.py@@ -54,6 +54,7 @@ def mint_long_lived_refresh_token(user, lifetime_seconds: int) -> str:# Imported lazily to avoid a hard dependency on the headless app at import# time (lets self-hosters with headless disabled still import this module).+ # Third Partyfrom allauth.headless.tokens.strategies.jwt.internal import create_refresh_tokenbackend = getattr(user, 'backend', None) or _DEFAULT_BACKEND