mirror of
https://github.com/wger-project/wger.git
synced 2026-02-18 00:17:51 +01:00
Rename checker class and configure more trophies
This commit is contained in:
@@ -14,9 +14,10 @@
|
||||
# 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/>.
|
||||
|
||||
# ruff: noqa: F401
|
||||
|
||||
# Local
|
||||
from .base import BaseTrophyChecker
|
||||
from .count_based import CountBasedChecker
|
||||
from .date_based import DateBasedChecker
|
||||
from .inactivity_return import InactivityReturnChecker
|
||||
from .registry import CheckerRegistry
|
||||
@@ -24,3 +25,4 @@ from .streak import StreakChecker
|
||||
from .time_based import TimeBasedChecker
|
||||
from .volume import VolumeChecker
|
||||
from .weekend_warrior import WeekendWarriorChecker
|
||||
from .workout_count_based import WorkoutCountBasedChecker
|
||||
|
||||
@@ -30,7 +30,6 @@ from wger.trophies.models.trophy import Trophy
|
||||
|
||||
# Local
|
||||
from .base import BaseTrophyChecker
|
||||
from .count_based import CountBasedChecker
|
||||
from .date_based import DateBasedChecker
|
||||
from .inactivity_return import InactivityReturnChecker
|
||||
from .personal_record import PersonalRecordChecker
|
||||
@@ -38,7 +37,7 @@ from .streak import StreakChecker
|
||||
from .time_based import TimeBasedChecker
|
||||
from .volume import VolumeChecker
|
||||
from .weekend_warrior import WeekendWarriorChecker
|
||||
|
||||
from .workout_count_based import WorkoutCountBasedChecker
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -54,7 +53,7 @@ class CheckerRegistry:
|
||||
# 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]] = {
|
||||
'count_based': CountBasedChecker,
|
||||
'workout_count_based': WorkoutCountBasedChecker,
|
||||
'streak': StreakChecker,
|
||||
'weekend_warrior': WeekendWarriorChecker,
|
||||
'volume': VolumeChecker,
|
||||
@@ -130,7 +129,7 @@ class CheckerRegistry:
|
||||
checker_class = cls.get_checker_class(trophy.checker_class)
|
||||
|
||||
if checker_class is None:
|
||||
logger.warning(
|
||||
logger.error(
|
||||
f'Checker class not found in registry: {trophy.checker_class} '
|
||||
f'for trophy: {trophy.name}'
|
||||
)
|
||||
|
||||
@@ -14,16 +14,13 @@
|
||||
# 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/>.
|
||||
|
||||
# Standard Library
|
||||
from typing import Any
|
||||
|
||||
# Local
|
||||
from .base import BaseTrophyChecker
|
||||
|
||||
|
||||
class CountBasedChecker(BaseTrophyChecker):
|
||||
class WorkoutCountBasedChecker(BaseTrophyChecker):
|
||||
"""
|
||||
Checker for count-based trophies.
|
||||
Checker for workout count-based trophies.
|
||||
|
||||
Used for trophies that require completing a certain number of workouts.
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 1,
|
||||
"fields": {
|
||||
"uuid": "5362e55b-eaf1-4e34-9ef8-661538a3bdd9",
|
||||
"uuid": "9f1c7c7e-3b2a-4b6f-9b5f-1c3e2d4f5a60",
|
||||
"name": "Beginner",
|
||||
"description": "Complete your first workout",
|
||||
"trophy_type": "count",
|
||||
"checker_class": "count_based",
|
||||
"checker_class": "workout_count_based",
|
||||
"checker_params": {"count": 1},
|
||||
"is_hidden": false,
|
||||
"is_progressive": false,
|
||||
@@ -21,14 +21,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 2,
|
||||
"fields": {
|
||||
"uuid": "b605b6a1-953d-41fb-87c9-a2f88b5f5907",
|
||||
"name": "Unstoppable",
|
||||
"description": "Maintain a 30-day workout streak",
|
||||
"trophy_type": "sequence",
|
||||
"checker_class": "streak",
|
||||
"checker_params": {"days": 30},
|
||||
"uuid": "0d2e3f4a-5b6c-47d8-9e0f-1a2b3c4d5e6f",
|
||||
"name": "Consistent",
|
||||
"description": "Complete 10 workouts",
|
||||
"trophy_type": "count",
|
||||
"checker_class": "workout_count_based",
|
||||
"checker_params": {"count": 10},
|
||||
"is_hidden": false,
|
||||
"is_progressive": true,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 2,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -39,14 +39,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 3,
|
||||
"fields": {
|
||||
"uuid": "bf60e051-a9a5-4bf5-ac4b-1aa713febca7",
|
||||
"name": "Weekend Warrior",
|
||||
"description": "Work out on Saturday and Sunday for 4 consecutive weekends",
|
||||
"trophy_type": "sequence",
|
||||
"checker_class": "weekend_warrior",
|
||||
"checker_params": {"weekends": 4},
|
||||
"uuid": "4b6f9c2d-3e1a-4f5b-8c7d-2e3f4a5b6c7d",
|
||||
"name": "Dedicated",
|
||||
"description": "Complete 50 workouts",
|
||||
"trophy_type": "count",
|
||||
"checker_class": "workout_count_based",
|
||||
"checker_params": {"count": 50},
|
||||
"is_hidden": false,
|
||||
"is_progressive": true,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 3,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -57,14 +57,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 4,
|
||||
"fields": {
|
||||
"uuid": "5353989b-adc0-481b-a9bc-64365a9179e8",
|
||||
"name": "Elephant lifter",
|
||||
"description": "Lift a cumulative total of 5.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 5000},
|
||||
"uuid": "d2c3b4a5-6f7e-48d9-8c0b-2a3c4d5e6f7b",
|
||||
"name": "Obsessed",
|
||||
"description": "Complete 100 workouts",
|
||||
"trophy_type": "count",
|
||||
"checker_class": "workout_count_based",
|
||||
"checker_params": {"count": 100},
|
||||
"is_hidden": false,
|
||||
"is_progressive": true,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 4,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -75,14 +75,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 5,
|
||||
"fields": {
|
||||
"uuid": "3c53887b-feba-4d73-8022-e446f46395c8",
|
||||
"name": "Bus lifter",
|
||||
"description": "Lift a cumulative total of 20.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 20000},
|
||||
"uuid": "e3f4a5b6-c7d8-49e0-9f1a-2b3c4d5e6f7a",
|
||||
"name": "Legend",
|
||||
"description": "Complete 200 workouts",
|
||||
"trophy_type": "count",
|
||||
"checker_class": "workout_count_based",
|
||||
"checker_params": {"count": 200},
|
||||
"is_hidden": false,
|
||||
"is_progressive": true,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 5,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -93,14 +93,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 6,
|
||||
"fields": {
|
||||
"uuid": "70ee1605-20b8-4c8d-87a1-3787b9b3939d",
|
||||
"name": "Plane lifter",
|
||||
"description": "Lift a cumulative total of 50.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 50000},
|
||||
"is_hidden": true,
|
||||
"is_progressive": true,
|
||||
"uuid": "f4a5b6c7-d8e9-40f1-9a2b-3c4d5e6f7a8b",
|
||||
"name": "Veteran",
|
||||
"description": "Complete 500 workouts",
|
||||
"trophy_type": "count",
|
||||
"checker_class": "workout_count_based",
|
||||
"checker_params": {"count": 500},
|
||||
"is_hidden": false,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 6,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -111,14 +111,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 7,
|
||||
"fields": {
|
||||
"uuid": "3b4521ee-14bc-4a31-a3d8-e6859e183a35",
|
||||
"name": "Blue whale lifter",
|
||||
"description": "Lift a cumulative total of 150.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 100000},
|
||||
"is_hidden": true,
|
||||
"is_progressive": true,
|
||||
"uuid": "a5b6c7d8-e9f0-41a2-9b3c-4d5e6f7a8b9c",
|
||||
"name": "Legend",
|
||||
"description": "Complete 1000 workouts",
|
||||
"trophy_type": "count",
|
||||
"checker_class": "workout_count_based",
|
||||
"checker_params": {"count": 1000},
|
||||
"is_hidden": false,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 7,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -129,13 +129,13 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 8,
|
||||
"fields": {
|
||||
"uuid": "f0a5fd12-2508-4654-89aa-3d6dbb29c7e3",
|
||||
"name": "Space Station lifter",
|
||||
"description": "Lift a cumulative total of 450.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 450000},
|
||||
"is_hidden": true,
|
||||
"uuid": "b605b6a1-953d-41fb-87c9-a2f88b5f5907",
|
||||
"name": "Unstoppable",
|
||||
"description": "Maintain a 30-day workout streak",
|
||||
"trophy_type": "sequence",
|
||||
"checker_class": "streak",
|
||||
"checker_params": {"days": 30},
|
||||
"is_hidden": false,
|
||||
"is_progressive": true,
|
||||
"is_active": true,
|
||||
"order": 8,
|
||||
@@ -147,13 +147,13 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 9,
|
||||
"fields": {
|
||||
"uuid": "2c770528-3528-4f0a-9d1a-342d96935bdf",
|
||||
"name": "Millionaire",
|
||||
"description": "Lift a cumulative total of 1.000.000 kg (that's a fully loaded space shuttle!)",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 1000000},
|
||||
"is_hidden": true,
|
||||
"uuid": "bf60e051-a9a5-4bf5-ac4b-1aa713febca7",
|
||||
"name": "Weekend Warrior",
|
||||
"description": "Work out on Saturday and Sunday for 4 consecutive weekends",
|
||||
"trophy_type": "sequence",
|
||||
"checker_class": "weekend_warrior",
|
||||
"checker_params": {"weekends": 4},
|
||||
"is_hidden": false,
|
||||
"is_progressive": true,
|
||||
"is_active": true,
|
||||
"order": 9,
|
||||
@@ -165,13 +165,13 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 10,
|
||||
"fields": {
|
||||
"uuid": "e414c29d-5828-4ca3-83b5-4837a71ed48f",
|
||||
"name": "Atlas",
|
||||
"description": "Lift a cumulative total of 10.000.000 kg",
|
||||
"uuid": "5353989b-adc0-481b-a9bc-64365a9179e8",
|
||||
"name": "Elephant lifter",
|
||||
"description": "Lift a cumulative total of 5.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 10000000},
|
||||
"is_hidden": true,
|
||||
"checker_params": {"kg": 5000},
|
||||
"is_hidden": false,
|
||||
"is_progressive": true,
|
||||
"is_active": true,
|
||||
"order": 10,
|
||||
@@ -183,14 +183,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 11,
|
||||
"fields": {
|
||||
"uuid": "cc833c0b-1fd9-4cde-baa5-3bff9cd97d0c",
|
||||
"name": "Early Bird",
|
||||
"description": "Complete a workout before 6:00 AM",
|
||||
"trophy_type": "time",
|
||||
"checker_class": "time_based",
|
||||
"checker_params": {"before": "06:00"},
|
||||
"uuid": "3c53887b-feba-4d73-8022-e446f46395c8",
|
||||
"name": "Bus lifter",
|
||||
"description": "Lift a cumulative total of 20.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 20000},
|
||||
"is_hidden": false,
|
||||
"is_progressive": false,
|
||||
"is_progressive": true,
|
||||
"is_active": true,
|
||||
"order": 11,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -201,14 +201,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 12,
|
||||
"fields": {
|
||||
"uuid": "2b00ff1e-69f8-47f0-b8df-976a4127a425",
|
||||
"name": "Night Owl",
|
||||
"description": "Complete a workout after 9:00 PM",
|
||||
"trophy_type": "time",
|
||||
"checker_class": "time_based",
|
||||
"checker_params": {"after": "21:00"},
|
||||
"is_hidden": false,
|
||||
"is_progressive": false,
|
||||
"uuid": "70ee1605-20b8-4c8d-87a1-3787b9b3939d",
|
||||
"name": "Plane lifter",
|
||||
"description": "Lift a cumulative total of 50.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 50000},
|
||||
"is_hidden": true,
|
||||
"is_progressive": true,
|
||||
"is_active": true,
|
||||
"order": 12,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -219,14 +219,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 13,
|
||||
"fields": {
|
||||
"uuid": "31a71d9a-bf26-4f18-b82f-afefe6f50df2",
|
||||
"name": "New Year, New Me",
|
||||
"description": "Work out on January 1st",
|
||||
"trophy_type": "date",
|
||||
"checker_class": "date_based",
|
||||
"checker_params": {"month": 1, "day": 1},
|
||||
"uuid": "3b4521ee-14bc-4a31-a3d8-e6859e183a35",
|
||||
"name": "Blue whale lifter",
|
||||
"description": "Lift a cumulative total of 150.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 100000},
|
||||
"is_hidden": true,
|
||||
"is_progressive": false,
|
||||
"is_progressive": true,
|
||||
"is_active": true,
|
||||
"order": 13,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -237,14 +237,14 @@
|
||||
"model": "trophies.trophy",
|
||||
"pk": 14,
|
||||
"fields": {
|
||||
"uuid": "32bb12da-b25f-4e18-81e4-b695eb65283e",
|
||||
"name": "Phoenix",
|
||||
"description": "Return to training after being inactive for 30 days",
|
||||
"trophy_type": "other",
|
||||
"checker_class": "inactivity_return",
|
||||
"checker_params": {"inactive_days": 30},
|
||||
"uuid": "f0a5fd12-2508-4654-89aa-3d6dbb29c7e3",
|
||||
"name": "Space Station lifter",
|
||||
"description": "Lift a cumulative total of 450.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 450000},
|
||||
"is_hidden": true,
|
||||
"is_progressive": false,
|
||||
"is_progressive": true,
|
||||
"is_active": true,
|
||||
"order": 14,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
@@ -254,6 +254,114 @@
|
||||
{
|
||||
"model": "trophies.trophy",
|
||||
"pk": 15,
|
||||
"fields": {
|
||||
"uuid": "2c770528-3528-4f0a-9d1a-342d96935bdf",
|
||||
"name": "Millionaire",
|
||||
"description": "Lift a cumulative total of 1.000.000 kg (that's a fully loaded space shuttle!)",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 1000000},
|
||||
"is_hidden": true,
|
||||
"is_progressive": true,
|
||||
"is_active": true,
|
||||
"order": 15,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
"updated": "2025-12-19T00:00:00Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "trophies.trophy",
|
||||
"pk": 16,
|
||||
"fields": {
|
||||
"uuid": "e414c29d-5828-4ca3-83b5-4837a71ed48f",
|
||||
"name": "Atlas",
|
||||
"description": "Lift a cumulative total of 10.000.000 kg",
|
||||
"trophy_type": "volume",
|
||||
"checker_class": "volume",
|
||||
"checker_params": {"kg": 10000000},
|
||||
"is_hidden": true,
|
||||
"is_progressive": true,
|
||||
"is_active": true,
|
||||
"order": 16,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
"updated": "2025-12-19T00:00:00Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "trophies.trophy",
|
||||
"pk": 17,
|
||||
"fields": {
|
||||
"uuid": "cc833c0b-1fd9-4cde-baa5-3bff9cd97d0c",
|
||||
"name": "Early Bird",
|
||||
"description": "Complete a workout before 6:00 AM",
|
||||
"trophy_type": "time",
|
||||
"checker_class": "time_based",
|
||||
"checker_params": {"before": "06:00"},
|
||||
"is_hidden": false,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 17,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
"updated": "2025-12-19T00:00:00Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "trophies.trophy",
|
||||
"pk": 18,
|
||||
"fields": {
|
||||
"uuid": "2b00ff1e-69f8-47f0-b8df-976a4127a425",
|
||||
"name": "Night Owl",
|
||||
"description": "Complete a workout after 9:00 PM",
|
||||
"trophy_type": "time",
|
||||
"checker_class": "time_based",
|
||||
"checker_params": {"after": "21:00"},
|
||||
"is_hidden": false,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 18,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
"updated": "2025-12-19T00:00:00Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "trophies.trophy",
|
||||
"pk": 19,
|
||||
"fields": {
|
||||
"uuid": "31a71d9a-bf26-4f18-b82f-afefe6f50df2",
|
||||
"name": "New Year, New Me",
|
||||
"description": "Work out on January 1st",
|
||||
"trophy_type": "date",
|
||||
"checker_class": "date_based",
|
||||
"checker_params": {"month": 1, "day": 1},
|
||||
"is_hidden": true,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 19,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
"updated": "2025-12-19T00:00:00Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "trophies.trophy",
|
||||
"pk": 20,
|
||||
"fields": {
|
||||
"uuid": "32bb12da-b25f-4e18-81e4-b695eb65283e",
|
||||
"name": "Phoenix",
|
||||
"description": "Return to training after being inactive for 30 days",
|
||||
"trophy_type": "other",
|
||||
"checker_class": "inactivity_return",
|
||||
"checker_params": {"inactive_days": 30},
|
||||
"is_hidden": true,
|
||||
"is_progressive": false,
|
||||
"is_active": true,
|
||||
"order": 20,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
"updated": "2025-12-19T00:00:00Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "trophies.trophy",
|
||||
"pk": 21,
|
||||
"fields": {
|
||||
"uuid": "d4a5dbe7-7e15-4f7c-8560-a19f5f27eb2e",
|
||||
"name": "Personal Record",
|
||||
@@ -264,7 +372,7 @@
|
||||
"is_hidden": true,
|
||||
"is_progressive": false,
|
||||
"is_repeatable": true,
|
||||
"order": 15,
|
||||
"order": 21,
|
||||
"created": "2025-12-19T00:00:00Z",
|
||||
"updated": "2025-12-19T00:00:00Z"
|
||||
}
|
||||
|
||||
@@ -12,19 +12,77 @@ volume_trophy_data = {
|
||||
'is_repeatable': False,
|
||||
}
|
||||
|
||||
workout_count_trophy_data = {
|
||||
'trophy_type': 'count',
|
||||
'checker_class': 'workout_count_based',
|
||||
'is_hidden': False,
|
||||
'is_progressive': True,
|
||||
'is_repeatable': False,
|
||||
}
|
||||
|
||||
# Define the initial trophies (same as in load_trophies management command)
|
||||
trophies_data = [
|
||||
{
|
||||
'uuid': '5362e55b-eaf1-4e34-9ef8-661538a3bdd9',
|
||||
**workout_count_trophy_data,
|
||||
'uuid': '9f1c7c7e-3b2a-4b6f-9b5f-1c3e2d4f5a60',
|
||||
'name': 'Beginner',
|
||||
'description': 'Complete your first workout',
|
||||
'trophy_type': 'count',
|
||||
'checker_class': 'count_based',
|
||||
'checker_params': {'count': 1},
|
||||
'is_hidden': False,
|
||||
'is_progressive': False,
|
||||
'order': 1,
|
||||
},
|
||||
{
|
||||
**workout_count_trophy_data,
|
||||
'uuid': '0d2e3f4a-5b6c-47d8-9e0f-1a2b3c4d5e6f',
|
||||
'name': 'Consistent',
|
||||
'description': 'Complete 10 workouts',
|
||||
'checker_params': {'count': 10},
|
||||
'is_hidden': False,
|
||||
'order': 2,
|
||||
},
|
||||
{
|
||||
**workout_count_trophy_data,
|
||||
'uuid': '4b6f9c2d-3e1a-4f5b-8c7d-2e3f4a5b6c7d',
|
||||
'name': 'Dedicated',
|
||||
'description': 'Complete 50 workouts',
|
||||
'checker_params': {'count': 50},
|
||||
'order': 3,
|
||||
},
|
||||
{
|
||||
**workout_count_trophy_data,
|
||||
'uuid': 'd2c3b4a5-6f7e-48d9-8c0b-2a3c4d5e6f7b',
|
||||
'name': 'Obsessed',
|
||||
'description': 'Complete 100 workouts',
|
||||
'checker_params': {'count': 100},
|
||||
'is_hidden': True,
|
||||
'order': 4,
|
||||
},
|
||||
{
|
||||
**workout_count_trophy_data,
|
||||
'uuid': 'e3f4a5b6-c7d8-49e0-9f1a-2b3c4d5e6f7a',
|
||||
'name': 'Legend',
|
||||
'description': 'Complete 200 workouts',
|
||||
'checker_params': {'count': 200},
|
||||
'is_hidden': True,
|
||||
'order': 5,
|
||||
},
|
||||
{
|
||||
**workout_count_trophy_data,
|
||||
'uuid': 'f4a5b6c7-d8e9-40f1-9a2b-3c4d5e6f7a8b',
|
||||
'name': 'Veteran',
|
||||
'description': 'Complete 500 workouts',
|
||||
'checker_params': {'count': 500},
|
||||
'is_hidden': True,
|
||||
'order': 6,
|
||||
},
|
||||
{
|
||||
**workout_count_trophy_data,
|
||||
'uuid': 'a5b6c7d8-e9f0-41a2-9b3c-4d5e6f7a8b9c',
|
||||
'name': 'Legend',
|
||||
'description': 'Complete 1000 workouts',
|
||||
'checker_params': {'count': 1000},
|
||||
'is_hidden': True,
|
||||
'order': 7,
|
||||
},
|
||||
{
|
||||
'uuid': 'b605b6a1-953d-41fb-87c9-a2f88b5f5907',
|
||||
'name': 'Unstoppable',
|
||||
@@ -32,9 +90,9 @@ trophies_data = [
|
||||
'trophy_type': 'sequence',
|
||||
'checker_class': 'streak',
|
||||
'checker_params': {'days': 30},
|
||||
'is_hidden': False,
|
||||
'is_progressive': True,
|
||||
'order': 2,
|
||||
'is_hidden': False,
|
||||
'order': 8,
|
||||
},
|
||||
{
|
||||
'uuid': 'bf60e051-a9a5-4bf5-ac4b-1aa713febca7',
|
||||
@@ -43,9 +101,9 @@ trophies_data = [
|
||||
'trophy_type': 'sequence',
|
||||
'checker_class': 'weekend_warrior',
|
||||
'checker_params': {'weekends': 4},
|
||||
'is_hidden': False,
|
||||
'is_progressive': True,
|
||||
'order': 3,
|
||||
'is_hidden': False,
|
||||
'order': 9,
|
||||
},
|
||||
{
|
||||
**volume_trophy_data,
|
||||
@@ -53,7 +111,7 @@ trophies_data = [
|
||||
'name': 'Elephant lifter',
|
||||
'description': 'Lift a cumulative total of 5.000 kg',
|
||||
'checker_params': {'kg': 5_000},
|
||||
'order': 4,
|
||||
'order': 10,
|
||||
},
|
||||
{
|
||||
**volume_trophy_data,
|
||||
@@ -61,7 +119,7 @@ trophies_data = [
|
||||
'name': 'Bus lifter',
|
||||
'description': 'Lift a cumulative total of 20.000 kg',
|
||||
'checker_params': {'kg': 20_000},
|
||||
'order': 5,
|
||||
'order': 11,
|
||||
},
|
||||
{
|
||||
**volume_trophy_data,
|
||||
@@ -69,7 +127,7 @@ trophies_data = [
|
||||
'name': 'Plane lifter',
|
||||
'description': 'Lift a cumulative total of 50.000 kg',
|
||||
'checker_params': {'kg': 50_000},
|
||||
'order': 6,
|
||||
'order': 12,
|
||||
},
|
||||
{
|
||||
**volume_trophy_data,
|
||||
@@ -77,8 +135,8 @@ trophies_data = [
|
||||
'name': 'Blue whale lifter',
|
||||
'description': 'Lift a cumulative total of 150.000 kg',
|
||||
'checker_params': {'kg': 150_000},
|
||||
'order': 7,
|
||||
'is_hidden':True,
|
||||
'order': 13,
|
||||
},
|
||||
{
|
||||
**volume_trophy_data,
|
||||
@@ -86,8 +144,8 @@ trophies_data = [
|
||||
'name': 'Space Station lifter',
|
||||
'description': 'Lift a cumulative total of 450.000 kg',
|
||||
'checker_params': {'kg': 450_000},
|
||||
'order': 8,
|
||||
'is_hidden':True,
|
||||
'order': 14,
|
||||
},
|
||||
{
|
||||
**volume_trophy_data,
|
||||
@@ -95,8 +153,8 @@ trophies_data = [
|
||||
'name': 'Millionaire',
|
||||
'description': 'Lift a cumulative total of 1.000.000 kg',
|
||||
'checker_params': {'kg': 1_000_000},
|
||||
'order': 9,
|
||||
'is_hidden':True,
|
||||
'order': 15,
|
||||
},
|
||||
{
|
||||
**volume_trophy_data,
|
||||
@@ -104,8 +162,8 @@ trophies_data = [
|
||||
'name': 'Atlas',
|
||||
'description': 'Lift a cumulative total of 10.000.000 kg',
|
||||
'checker_params': {'kg': 10_000_000},
|
||||
'order': 10,
|
||||
'is_hidden':True,
|
||||
'order': 16,
|
||||
},
|
||||
{
|
||||
'uuid': 'cc833c0b-1fd9-4cde-baa5-3bff9cd97d0c',
|
||||
@@ -116,7 +174,7 @@ trophies_data = [
|
||||
'checker_params': {'before': '06:00'},
|
||||
'is_hidden': False,
|
||||
'is_progressive': False,
|
||||
'order': 11,
|
||||
'order': 17,
|
||||
},
|
||||
{
|
||||
'uuid': '2b00ff1e-69f8-47f0-b8df-976a4127a425',
|
||||
@@ -127,7 +185,7 @@ trophies_data = [
|
||||
'checker_params': {'after': '21:00'},
|
||||
'is_hidden': False,
|
||||
'is_progressive': False,
|
||||
'order': 12,
|
||||
'order': 18,
|
||||
},
|
||||
{
|
||||
'uuid': '31a71d9a-bf26-4f18-b82f-afefe6f50df2',
|
||||
@@ -138,7 +196,7 @@ trophies_data = [
|
||||
'checker_params': {'month': 1, 'day': 1},
|
||||
'is_hidden': True,
|
||||
'is_progressive': False,
|
||||
'order': 13,
|
||||
'order': 19,
|
||||
},
|
||||
{
|
||||
'uuid': '32bb12da-b25f-4e18-81e4-b695eb65283e',
|
||||
@@ -149,7 +207,7 @@ trophies_data = [
|
||||
'checker_params': {'inactive_days': 30},
|
||||
'is_hidden': True,
|
||||
'is_progressive': False,
|
||||
'order': 14,
|
||||
'order': 20,
|
||||
},
|
||||
{
|
||||
'uuid': 'd4a5dbe7-7e15-4f7c-8560-a19f5f27eb2e',
|
||||
@@ -161,7 +219,7 @@ trophies_data = [
|
||||
'is_hidden': True,
|
||||
'is_progressive': False,
|
||||
'is_repeatable': True,
|
||||
'order': 15,
|
||||
'order': 21,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ class Trophy(models.Model):
|
||||
@property
|
||||
def image_rel_path(self):
|
||||
"""
|
||||
Returns the relative path to the trophy image
|
||||
Returns the relative (to the static folder) path to the trophy image
|
||||
"""
|
||||
return 'trophies/placeholder.png'
|
||||
# return f'trophies/{self.trophy_type}/{self.uuid}.png'
|
||||
|
||||
@@ -24,13 +24,13 @@ from wger.core.tests.base_testcase import WgerTestCase
|
||||
from wger.exercises.models.base import Exercise
|
||||
from wger.exercises.models.category import ExerciseCategory
|
||||
from wger.manager.models.log import WorkoutLog
|
||||
from wger.trophies.checkers.count_based import CountBasedChecker
|
||||
from wger.trophies.checkers.date_based import DateBasedChecker
|
||||
from wger.trophies.checkers.inactivity_return import InactivityReturnChecker
|
||||
from wger.trophies.checkers.streak import StreakChecker
|
||||
from wger.trophies.checkers.time_based import TimeBasedChecker
|
||||
from wger.trophies.checkers.volume import VolumeChecker
|
||||
from wger.trophies.checkers.weekend_warrior import WeekendWarriorChecker
|
||||
from wger.trophies.checkers.workout_count_based import WorkoutCountBasedChecker
|
||||
from wger.trophies.models import (
|
||||
Trophy,
|
||||
UserStatistics,
|
||||
@@ -58,7 +58,7 @@ class CountBasedCheckerTestCase(WgerTestCase):
|
||||
self.stats.total_workouts = 5
|
||||
self.stats.save()
|
||||
|
||||
checker = CountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
checker = WorkoutCountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
self.assertFalse(checker.check())
|
||||
|
||||
def test_check_achieved(self):
|
||||
@@ -66,7 +66,7 @@ class CountBasedCheckerTestCase(WgerTestCase):
|
||||
self.stats.total_workouts = 10
|
||||
self.stats.save()
|
||||
|
||||
checker = CountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
checker = WorkoutCountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
self.assertTrue(checker.check())
|
||||
|
||||
def test_check_exceeded(self):
|
||||
@@ -74,7 +74,7 @@ class CountBasedCheckerTestCase(WgerTestCase):
|
||||
self.stats.total_workouts = 15
|
||||
self.stats.save()
|
||||
|
||||
checker = CountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
checker = WorkoutCountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
self.assertTrue(checker.check())
|
||||
|
||||
def test_progress_calculation(self):
|
||||
@@ -82,7 +82,7 @@ class CountBasedCheckerTestCase(WgerTestCase):
|
||||
self.stats.total_workouts = 5
|
||||
self.stats.save()
|
||||
|
||||
checker = CountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
checker = WorkoutCountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
self.assertEqual(checker.get_progress(), 50.0)
|
||||
|
||||
def test_progress_capped_at_100(self):
|
||||
@@ -90,7 +90,7 @@ class CountBasedCheckerTestCase(WgerTestCase):
|
||||
self.stats.total_workouts = 15
|
||||
self.stats.save()
|
||||
|
||||
checker = CountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
checker = WorkoutCountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
self.assertEqual(checker.get_progress(), 100.0)
|
||||
|
||||
def test_get_current_value(self):
|
||||
@@ -98,12 +98,12 @@ class CountBasedCheckerTestCase(WgerTestCase):
|
||||
self.stats.total_workouts = 7
|
||||
self.stats.save()
|
||||
|
||||
checker = CountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
checker = WorkoutCountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
self.assertEqual(checker.get_current_value(), 7)
|
||||
|
||||
def test_get_target_value(self):
|
||||
"""Test getting target workout count"""
|
||||
checker = CountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
checker = WorkoutCountBasedChecker(self.user, self.trophy, {'count': 10})
|
||||
self.assertEqual(checker.get_target_value(), 10)
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class TrophyIntegrationTestCase(WgerTestCase):
|
||||
self.beginner_trophy = Trophy.objects.create(
|
||||
name='Beginner',
|
||||
trophy_type=Trophy.TYPE_COUNT,
|
||||
checker_class='count_based',
|
||||
checker_class='workout_count_based',
|
||||
checker_params={'count': 1},
|
||||
is_active=True,
|
||||
)
|
||||
@@ -306,7 +306,7 @@ class TrophyIntegrationTestCase(WgerTestCase):
|
||||
hidden_trophy = Trophy.objects.create(
|
||||
name='Secret Achievement',
|
||||
trophy_type=Trophy.TYPE_COUNT,
|
||||
checker_class='count_based',
|
||||
checker_class='workout_count_based',
|
||||
checker_params={'count': 100},
|
||||
is_active=True,
|
||||
is_hidden=True,
|
||||
|
||||
@@ -129,7 +129,7 @@ class TrophyServiceTestCase(WgerTestCase):
|
||||
self.trophy = Trophy.objects.create(
|
||||
name='Test Trophy',
|
||||
trophy_type=Trophy.TYPE_COUNT,
|
||||
checker_class='count_based',
|
||||
checker_class='workout_count_based',
|
||||
checker_params={'count': 1},
|
||||
is_active=True,
|
||||
)
|
||||
@@ -270,7 +270,7 @@ class TrophyServiceTestCase(WgerTestCase):
|
||||
hidden_trophy = Trophy.objects.create(
|
||||
name='Hidden',
|
||||
trophy_type=Trophy.TYPE_COUNT,
|
||||
checker_class='count_based',
|
||||
checker_class='workout_count_based',
|
||||
checker_params={'count': 10},
|
||||
is_hidden=True,
|
||||
is_active=True,
|
||||
@@ -287,7 +287,7 @@ class TrophyServiceTestCase(WgerTestCase):
|
||||
hidden_trophy = Trophy.objects.create(
|
||||
name='Hidden',
|
||||
trophy_type=Trophy.TYPE_COUNT,
|
||||
checker_class='count_based',
|
||||
checker_class='workout_count_based',
|
||||
checker_params={'count': 1},
|
||||
is_hidden=True,
|
||||
is_active=True,
|
||||
@@ -379,7 +379,7 @@ class TrophyServiceTestCase(WgerTestCase):
|
||||
trophy2 = Trophy.objects.create(
|
||||
name='Trophy 2',
|
||||
trophy_type=Trophy.TYPE_COUNT,
|
||||
checker_class='count_based',
|
||||
checker_class='workout_count_based',
|
||||
checker_params={'count': 5},
|
||||
is_active=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user