Self hosted FLOSS fitness/workout, nutrition and weight tracker
Fix Phase 1 & 2: Add admin config, weekend tracking, simple registry keys
HairyCrabW79d7fb751930
diff --git a/wger/trophies/admin.py b/wger/trophies/admin.pynew file mode 100644index 000000000..631f4548b--- /dev/null+++ b/wger/trophies/admin.py@@ -0,0 +1,74 @@+# This file is part of wger Workout Manager <https://github.com/wger-project>.+# Copyright (C) 2013 - 2021 wger Team+#+# wger Workout Manager is free software: you can redistribute it and/or modify+# it under the terms of the GNU Affero General Public License as published by+# the Free Software Foundation, either version 3 of the License, or+# (at your option) any later version.+#+# wger Workout Manager is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU Affero General Public License for more details.+#+# You should have received a copy of the GNU Affero General Public License+# along with this program. If not, see <http://www.gnu.org/licenses/>.++# Django+from django.contrib import admin++# Local+from wger.trophies.models import (+ Trophy,+ UserStatistics,+ UserTrophy,+)++[email protected](Trophy)+class TrophyAdmin(admin.ModelAdmin):+ """Admin configuration for Trophy model"""++ list_display = (+ 'name',+ 'trophy_type',+ 'checker_class',+ 'is_active',+ 'is_hidden',+ 'is_progressive',+ 'order',+ )+ list_filter = ('trophy_type', 'is_active', 'is_hidden', 'is_progressive')+ search_fields = ('name', 'description')+ ordering = ('order', 'name')+ readonly_fields = ('uuid', 'created', 'updated')++[email protected](UserTrophy)+class UserTrophyAdmin(admin.ModelAdmin):+ """Admin configuration for UserTrophy model"""++ list_display = ('user', 'trophy', 'earned_at', 'progress', 'is_notified')+ list_filter = ('trophy', 'is_notified', 'earned_at')+ search_fields = ('user__username', 'trophy__name')+ ordering = ('-earned_at',)+ raw_id_fields = ('user',)++[email protected](UserStatistics)+class UserStatisticsAdmin(admin.ModelAdmin):+ """Admin configuration for UserStatistics model"""++ list_display = (+ 'user',+ 'total_workouts',+ 'total_weight_lifted',+ 'current_streak',+ 'longest_streak',+ 'last_workout_date',+ 'last_updated',+ )+ search_fields = ('user__username',)+ ordering = ('-last_updated',)+ raw_id_fields = ('user',)+ readonly_fields = ('last_updated',)diff --git a/wger/trophies/checkers/registry.py b/wger/trophies/checkers/registry.pyindex 2d0b0726e..b7b5dee1c 100644--- a/wger/trophies/checkers/registry.py+++ b/wger/trophies/checkers/registry.py@@ -47,15 +47,16 @@ class CheckerRegistry:actual Python classes."""- # Registry mapping checker class paths to actual classes+ # Registry mapping simple keys to checker classes+ # Using simple keys instead of full Python paths to avoid breakage if module structure changes_registry: Dict[str, Type[BaseTrophyChecker]] = {- 'wger.trophies.checkers.CountBasedChecker': CountBasedChecker,- 'wger.trophies.checkers.StreakChecker': StreakChecker,- 'wger.trophies.checkers.WeekendWarriorChecker': WeekendWarriorChecker,- 'wger.trophies.checkers.VolumeChecker': VolumeChecker,- 'wger.trophies.checkers.TimeBasedChecker': TimeBasedChecker,- 'wger.trophies.checkers.DateBasedChecker': DateBasedChecker,- 'wger.trophies.checkers.InactivityReturnChecker': InactivityReturnChecker,+ 'count_based': CountBasedChecker,+ 'streak': StreakChecker,+ 'weekend_warrior': WeekendWarriorChecker,+ 'volume': VolumeChecker,+ 'time_based': TimeBasedChecker,+ 'date_based': DateBasedChecker,+ 'inactivity_return': InactivityReturnChecker,}@classmethoddiff --git a/wger/trophies/migrations/0002_add_last_complete_weekend_date.py b/wger/trophies/migrations/0002_add_last_complete_weekend_date.pynew file mode 100644index 000000000..96a478484--- /dev/null+++ b/wger/trophies/migrations/0002_add_last_complete_weekend_date.py@@ -0,0 +1,18 @@+# Generated by Django 5.2.8 on 2025-12-02 11:46++from django.db import migrations, models+++class Migration(migrations.Migration):++ dependencies = [+ ('trophies', '0001_initial'),+ ]++ operations = [+ migrations.AddField(+ model_name='userstatistics',+ name='last_complete_weekend_date',+ field=models.DateField(blank=True, help_text='Date of the last Saturday where both Sat and Sun had workouts', null=True, verbose_name='Last complete weekend date'),+ ),+ ]diff --git a/wger/trophies/models/user_statistics.py b/wger/trophies/models/user_statistics.pyindex 66b852db4..21a8afb31 100644--- a/wger/trophies/models/user_statistics.py+++ b/wger/trophies/models/user_statistics.py@@ -96,6 +96,14 @@ class UserStatistics(models.Model):)"""Consecutive weekends with workouts on both Saturday and Sunday"""+ last_complete_weekend_date = models.DateField(+ null=True,+ blank=True,+ verbose_name=_('Last complete weekend date'),+ help_text=_('Date of the last Saturday where both Sat and Sun had workouts'),+ )+ """Used for tracking consecutive weekend workouts"""+last_inactive_date = models.DateField(null=True,blank=True,