Self hosted FLOSS fitness/workout, nutrition and weight tracker
Fix tests and post-rebase cleanup
Roland Geider3431ea5fba63
diff --git a/settings/main.py b/settings/main.pyindex dad42d30b..b437c6972 100644--- a/settings/main.py+++ b/settings/main.py@@ -263,10 +263,11 @@ AXES_IPWARE_META_PRECEDENCE_ORDER = env.list(# Django-allauth social providers#WGER_SOCIAL_PROVIDERS = env.list('WGER_SOCIAL_PROVIDERS', default=[])+# allauth.socialaccount itself is always installed (see settings_global.py) so+# its models stay importable. Only the per-provider apps are env-gated.if WGER_SOCIAL_PROVIDERS:INSTALLED_APPS += [- 'allauth.socialaccount',- *[f'allauth.socialaccount.providers.{p}' for p in WGER_SOCIAL_PROVIDERS],+ f'allauth.socialaccount.providers.{p}' for p in WGER_SOCIAL_PROVIDERS]#diff --git a/settings/settings_global.py b/settings/settings_global.pyindex 85bd585e9..ddc975fee 100644--- a/settings/settings_global.py+++ b/settings/settings_global.py@@ -127,7 +127,8 @@ INSTALLED_APPS = ['allauth.mfa','allauth.headless','allauth.socialaccount',- 'allauth.socialaccount.providers.google',+ # Per-provider apps (allauth.socialaccount.providers.google, ...) are+ # added conditionally in main.py based on WGER_SOCIAL_PROVIDERS.# Dj-rest-auth'dj_rest_auth',@@ -242,11 +243,6 @@ ACCOUNT_CHANGE_EMAIL = True# authentication backend resolves the email against its EmailAddress table.ACCOUNT_LOGIN_METHODS = {'username', 'email'}-# Treat a user as having a single email address: changing it adds a pending-# address that only replaces the current one (and updates User.email) once-# confirmed via the verification link.-ACCOUNT_CHANGE_EMAIL = True-# Use wger's own login/signup forms (allauth's forms + the password-visibility# toggle, and a conditional reCAPTCHA field on signup).ACCOUNT_FORMS = {diff --git a/uv.lock b/uv.lockindex ab0ed519b..699dcbdfb 100644--- a/uv.lock+++ b/uv.lock@@ -463,6 +463,16 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/d2/f1/00ce3bde3ca542d1acd8f8cfa38e446840945aa6363f9b74746394b14127/cryptography-46.0.7-cp38-abi3-win_amd64.whl", hash = "sha256:506c4ff91eff4f82bdac7633318a526b1d1309fc07ca76a3ad182cb5b686d6d3", size = 3472985, upload-time = "2026-04-08T01:57:36.714Z" },]+[[package]]+name = "dj-rest-auth"+version = "7.2.0"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "django" },+ { name = "djangorestframework" },+]+sdist = { url = "https://files.pythonhosted.org/packages/14/fd/c8a185a98f6860b802dc5e663c652efc01cd68f4e046c65f8cb9328c0077/dj_rest_auth-7.2.0.tar.gz", hash = "sha256:f77af37da5cf6ee28f03f283a378a2f5761860e72d1d6f2fa3d50e6286000482", size = 490126, upload-time = "2026-03-15T04:05:39.272Z" }+[[package]]name = "django"version = "6.0.5"@@ -1917,6 +1927,7 @@ dependencies = [{ name = "boto3" },{ name = "celery", extra = ["redis"] },{ name = "crispy-bootstrap5" },+ { name = "dj-rest-auth" },{ name = "django" },{ name = "django-activity-stream" },{ name = "django-allauth", extra = ["mfa"] },@@ -1977,6 +1988,7 @@ requires-dist = [{ name = "boto3", specifier = "~=1.43.2" },{ name = "celery", extras = ["redis"], specifier = "~=5.6.0" },{ name = "crispy-bootstrap5", specifier = "~=2026.3" },+ { name = "dj-rest-auth", specifier = "~=7.2.0" },{ name = "django", specifier = "~=6.0.5" },{ name = "django-activity-stream", specifier = "~=2.0.0" },{ name = "django-allauth", extras = ["mfa"], specifier = "~=65.16.1" },diff --git a/wger/core/migrations/0023_backfill_emailaddress.py b/wger/core/migrations/0024_backfill_emailaddress.pysimilarity index 95%rename from wger/core/migrations/0023_backfill_emailaddress.pyrename to wger/core/migrations/0024_backfill_emailaddress.pyindex a2399dfd1..20e942856 100644--- a/wger/core/migrations/0023_backfill_emailaddress.py+++ b/wger/core/migrations/0024_backfill_emailaddress.py@@ -39,7 +39,7 @@ def backfill_email_addresses(apps, schema_editor):class Migration(migrations.Migration):dependencies = [- ('core', '0022_move_email_verified_to_emailaddress'),+ ('core', '0023_create_publication'),('account', '0001_initial'),]diff --git a/wger/core/templates/account/login.html b/wger/core/templates/account/login.htmlindex 79bdb8b59..69b157747 100644--- a/wger/core/templates/account/login.html+++ b/wger/core/templates/account/login.html@@ -64,6 +64,10 @@{% translate "Sign in with a passkey" %}</button>{% endif %}++ {% if use_social_auth %}+ {% include "user/social_login.html" %}+ {% endif %}{% endblock %}diff --git a/wger/core/tests/test_auth_social.py b/wger/core/tests/test_auth_social.pyindex e59b15055..92007b9d8 100644--- a/wger/core/tests/test_auth_social.py+++ b/wger/core/tests/test_auth_social.py@@ -17,7 +17,6 @@from unittest import mock# Django-from django.conf import settingsfrom django.test import (RequestFactory,SimpleTestCase,@@ -43,10 +42,7 @@ class _StubProvider:return '/accounts/wger-social/login/'-@override_settings(- INSTALLED_APPS=[*settings.INSTALLED_APPS, 'allauth.socialaccount'],- WGER_SOCIAL_PROVIDERS=['wger'],-)+@override_settings(WGER_SOCIAL_PROVIDERS=['wger'])class SocialAuthEnabledLoginPageTestCase(WgerTestCase):"""When social auth is enabled, the login page renders the provider section."""diff --git a/wger/core/tests/test_verification.py b/wger/core/tests/test_verification.pyindex 52e777765..e7ccf3b3c 100644--- a/wger/core/tests/test_verification.py+++ b/wger/core/tests/test_verification.py@@ -34,87 +34,6 @@ from wger.core.tests.base_testcase import WgerTestCaselogger = logging.getLogger(__name__)-@override_settings(EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend')-class EmailVerificationFromPreferencesTestCase(WgerTestCase):- """- Tests that clicking the verification link in the preferences sidebar- sends a verification email via allauth.- """-- def test_confirm_email_sends_mail_for_unverified_user(self):- """- An unverified user clicking confirm-email receives a verification email- """-- # User 1 (admin) has verified=False in the fixtures- self.user_login('admin')-- mail.outbox = []- response = self.client.get(reverse('core:user:confirm-email'))-- # Redirects to dashboard- self.assertEqual(response.status_code, 302)- self.assertIn(reverse('core:dashboard'), response.url)-- # A verification email was sent- self.assertEqual(len(mail.outbox), 1)- self.assertIn('[email protected]', mail.outbox[0].to)-- def test_confirm_email_link_verifies_email(self):- """- Following the confirmation link from the email marks the address as verified- """-- # User 1 (admin) has verified=False in the fixtures- self.user_login('admin')-- mail.outbox = []- self.client.get(reverse('core:user:confirm-email'))- self.assertEqual(len(mail.outbox), 1)-- # Extract the confirmation key from the email body- email_body = mail.outbox[0].body- match = re.search(r'/accounts/confirm-email/([^/\s]+)/', email_body)- self.assertIsNotNone(match, 'Could not find confirmation link in email body')- key = match.group(1)-- # Visit the confirmation URL (GET shows the page, POST confirms)- confirm_url = reverse('account_confirm_email', args=[key])- self.client.get(confirm_url)-- # The email should now be verified- user = User.objects.get(username='admin')- email_obj = EmailAddress.objects.get_for_user(user, user.email)- self.assertTrue(email_obj.verified)-- def test_confirm_email_no_mail_for_verified_user(self):- """- A verified user clicking confirm-email does not receive a new email- """-- # User 4 (trainer1) has verified=True in the fixtures- self.user_login('trainer1')-- mail.outbox = []- response = self.client.get(reverse('core:user:confirm-email'))-- # Redirects to dashboard- self.assertEqual(response.status_code, 302)-- # No email was sent- self.assertEqual(len(mail.outbox), 0)-- def test_confirm_email_requires_login(self):- """- Anonymous users are redirected to the login page- """-- self.user_logout()- response = self.client.get(reverse('core:user:confirm-email'))- self.assertEqual(response.status_code, 302)- self.assertIn('/login', response.url)--@override_settings(EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend')class EmailVerificationFromAPITestCase(WgerTestCase):"""diff --git a/wger/manager/tests/test_api_ownership_checks.py b/wger/manager/tests/test_api_ownership_checks.pyindex bf6d32f04..da3a40ae5 100644--- a/wger/manager/tests/test_api_ownership_checks.py+++ b/wger/manager/tests/test_api_ownership_checks.py@@ -102,7 +102,7 @@ class WorkoutLogNextLogOwnershipTestCase(WgerTestCase):nulls the field, but the API should respond with 403 for consistencywith the other foreign keys on this resource.- The seed log belongs to user 'admin' (pk=1).+ WorkoutLog aaaaaaaa-aaaa-aaaa-aaaa-000000000001 belongs to user 'admin' (pk=1).Routine pk=3 belongs to user 'test' (pk=2)."""