Self hosted FLOSS fitness/workout, nutrition and weight tracker
Load bases when creating the demo workouts
Roland Geider9705a071c58c
diff --git a/wger/core/demo.py b/wger/core/demo.pyindex 91fa2c810..4db069e10 100644--- a/wger/core/demo.py+++ b/wger/core/demo.py@@ -27,7 +27,7 @@ from django.utils.translation import gettext as _# wgerfrom wger.core.models import DaysOfWeek-from wger.exercises.models import Exercise+from wger.exercises.models import Exercise, ExerciseBasefrom wger.manager.models import (Day,Schedule,@@ -50,6 +50,12 @@ from wger.weight.models import WeightEntrylogger = logging.getLogger(__name__)+UUID_SQUATS = 'a2f5b6ef-b780-49c0-8d96-fdaff23e27ce'+UUID_CURLS = '1ae6a28d-10e7-4ecf-af4f-905f8193e2c6'+UUID_FRENCH_PRESS = '95a7e546-e8f8-4521-a76b-983d94161b25'+UUID_CRUNCHES = 'b186f1f8-4957-44dc-bf30-d0b00064ce6f'+UUID_LEG_RAISES = 'c2078aac-e4e2-4103-a845-6252a3eb795e'+def create_temporary_user():"""@@ -96,14 +102,11 @@ def create_demo_entries(user):day2.day.add(wednesday)# Biceps curls with dumbbell- if language.short_name == 'de':- exercise = Exercise.objects.get(pk=26)- else:- exercise = Exercise.objects.get(pk=81)+ base = ExerciseBase.objects.get(uuid=UUID_CURLS)day_set = Set(exerciseday=day, sets=4, order=2)day_set.save()- setting = Setting(set=day_set, exercise_base=exercise.exercise_base, reps=8, order=1)+ setting = Setting(set=day_set, exercise_base=base, reps=8, order=1)setting.save()# Weight log entries@@ -111,7 +114,7 @@ def create_demo_entries(user):for i in range(1, 8):log = WorkoutLog(user=user,- exercise_base=exercise.exercise_base,+ exercise_base=base,workout=workout,reps=reps,weight=18 - reps + random.randint(1, 4),@@ -120,21 +123,18 @@ def create_demo_entries(user):weight_log.append(log)# French press- if language.short_name == 'de':- exercise = Exercise.objects.get(pk=25)- else:- exercise = Exercise.objects.get(pk=84)+ base = ExerciseBase.objects.get(uuid=UUID_FRENCH_PRESS)day_set = Set(exerciseday=day, sets=4, order=2)day_set.save()- setting_list.append(Setting(set=day_set, exercise_base=exercise.exercise_base, reps=8, order=1))+ setting_list.append(Setting(set=day_set, exercise_base=base, reps=8, order=1))# Weight log entriesfor reps in (7, 10):for i in range(1, 8):log = WorkoutLog(user=user,- exercise_base=exercise.exercise_base,+ exercise_base=base,workout=workout,reps=reps,weight=30 - reps + random.randint(1, 4),@@ -143,15 +143,12 @@ def create_demo_entries(user):weight_log.append(log)# Squats- if language.short_name == 'de':- exercise = Exercise.objects.get(pk=6)- else:- exercise = Exercise.objects.get(pk=111)+ base = ExerciseBase.objects.get(uuid=UUID_SQUATS)day_set = Set(exerciseday=day, sets=4, order=3)day_set.save()setting_list.append(- Setting(set=day_set, exercise_base=exercise.exercise_base, reps=10, order=1)+ Setting(set=day_set, exercise_base=base, reps=10, order=1))# Weight log entries@@ -159,7 +156,7 @@ def create_demo_entries(user):for i in range(1, 8):log = WorkoutLog(user=user,- exercise_base=exercise.exercise_base,+ exercise_base=base,workout=workout,reps=reps,weight=110 - reps + random.randint(1, 10),@@ -168,37 +165,31 @@ def create_demo_entries(user):weight_log.append(log)# Crunches- if language.short_name == 'de':- exercise = Exercise.objects.get(pk=4)- else:- exercise = Exercise.objects.get(pk=91)+ base = ExerciseBase.objects.get(uuid=UUID_CRUNCHES)day_set = Set(exerciseday=day, sets=4, order=4)day_set.save()setting_list.append(- Setting(set=day_set, exercise_base=exercise.exercise_base, reps=30, order=1)+ Setting(set=day_set, exercise_base=base, reps=30, order=1))setting_list.append(- Setting(set=day_set, exercise_base=exercise.exercise_base, reps=99, order=2)+ Setting(set=day_set, exercise_base=base, reps=99, order=2))setting_list.append(- Setting(set=day_set, exercise_base=exercise.exercise_base, reps=35, order=3)+ Setting(set=day_set, exercise_base=base, reps=35, order=3))# Leg raises, supersets with crunches- if language.short_name == 'de':- exercise = Exercise.objects.get(pk=35)- else:- exercise = Exercise.objects.get(pk=126)+ base = ExerciseBase.objects.get(uuid=UUID_LEG_RAISES)setting_list.append(- Setting(set=day_set, exercise_base=exercise.exercise_base, reps=30, order=1)+ Setting(set=day_set, exercise_base=base, reps=30, order=1))setting_list.append(- Setting(set=day_set, exercise_base=exercise.exercise_base, reps=40, order=2)+ Setting(set=day_set, exercise_base=base, reps=40, order=2))setting_list.append(- Setting(set=day_set, exercise_base=exercise.exercise_base, reps=99, order=3)+ Setting(set=day_set, exercise_base=base, reps=99, order=3))Setting.objects.bulk_create(setting_list)diff --git a/wger/core/tests/test_sitemap.py b/wger/core/tests/test_sitemap.pyindex 16902631f..31724382b 100644--- a/wger/core/tests/test_sitemap.py+++ b/wger/core/tests/test_sitemap.py@@ -36,7 +36,7 @@ class SitemapTestCase(WgerTestCase):reverse('django.contrib.sitemaps.views.sitemap', kwargs={'section': 'exercises'}))self.assertEqual(response.status_code, 200)- self.assertEqual(len(response.context['urlset']), 12)+ self.assertEqual(len(response.context['urlset']), 11)def test_sitemap_ingredients(self):diff --git a/wger/core/tests/test_temporary_users.py b/wger/core/tests/test_temporary_users.pyindex 1fb425a69..bbb648d10 100644--- a/wger/core/tests/test_temporary_users.py+++ b/wger/core/tests/test_temporary_users.py@@ -113,7 +113,7 @@ class DemoUserTestCase(WgerTestCase):for i in range(1, 5):creation_date = datetime.date.today() - datetime.timedelta(days=i)entry = WeightEntry(- user=user, weight=80 + 0.5 * i + random.randint(1, 3), date=creation_date+ user=user, weight=80 + 0.5 * i + random.randint(1, 3), date=creation_date,)temp.append(entry)WeightEntry.objects.bulk_create(temp)diff --git a/wger/exercises/fixtures/test-exercises.json b/wger/exercises/fixtures/test-exercises.jsonindex 65bc78802..3e3f988b2 100644--- a/wger/exercises/fixtures/test-exercises.json+++ b/wger/exercises/fixtures/test-exercises.json@@ -77,7 +77,7 @@"pk": 4,"model": "exercises.exercisebase","fields": {- "uuid": "9838235ce38f4ca6921e9d237d8e0813",+ "uuid": "a2f5b6ef-b780-49c0-8d96-fdaff23e27ce","category": 3,"creation_date": "2022-01-10","update_date": "2022-02-02T06:45:11+01:00",@@ -92,7 +92,43 @@"pk": 5,"model": "exercises.exercisebase","fields": {- "uuid": "e9e35f0c45b14d64b00db707a94c6fb8",+ "uuid": "1ae6a28d-10e7-4ecf-af4f-905f8193e2c6",+ "category": 1,+ "creation_date": "2002-08-15",+ "update_date": "2008-08-08T08:08:08+01:00",+ "muscles": [],+ "variations": null+ }+ },+ {+ "pk": 6,+ "model": "exercises.exercisebase",+ "fields": {+ "uuid": "95a7e546-e8f8-4521-a76b-983d94161b25",+ "category": 1,+ "creation_date": "2002-08-15",+ "update_date": "2008-08-08T08:08:08+01:00",+ "muscles": [],+ "variations": null+ }+ },+ {+ "pk": 7,+ "model": "exercises.exercisebase",+ "fields": {+ "uuid": "b186f1f8-4957-44dc-bf30-d0b00064ce6f",+ "category": 1,+ "creation_date": "2002-08-15",+ "update_date": "2008-08-08T08:08:08+01:00",+ "muscles": [],+ "variations": null+ }+ },+ {+ "pk": 8,+ "model": "exercises.exercisebase",+ "fields": {+ "uuid": "c2078aac-e4e2-4103-a845-6252a3eb795e","category": 1,"creation_date": "2002-08-15","update_date": "2008-08-08T08:08:08+01:00",@@ -182,7 +218,7 @@}},{- "pk": 35,+ "pk": 7,"model": "exercises.exercise","fields": {"uuid": "150f17eb8674450d976f4c5538479bfb",@@ -195,7 +231,7 @@}},{- "pk": 81,+ "pk": 8,"model": "exercises.exercise","fields": {"uuid": "885c1110aa324235af361164347a4465",@@ -208,12 +244,12 @@}},{- "pk": 84,+ "pk": 9,"model": "exercises.exercise","fields": {"uuid": "a7c662b36b474affb313a872a104dd2f","language": 2,- "exercise_base": 4,+ "exercise_base": 6,"description": "","name": "Needed for demo user","creation_date": "2022-01-10",@@ -221,12 +257,12 @@}},{- "pk": 91,+ "pk": 10,"model": "exercises.exercise","fields": {"uuid": "f2417bb4fa314e51bd5c425af21be468","language": 2,- "exercise_base": 4,+ "exercise_base": 7,"description": "","name": "Needed for demo user","creation_date": "2022-01-10",@@ -234,25 +270,12 @@}},{- "pk": 111,+ "pk": 11,"model": "exercises.exercise","fields": {"uuid": "cc3dbb66889f4deda2f0142c942c464f","language": 2,- "exercise_base": 4,- "description": "",- "name": "Needed for demo user",- "creation_date": "2022-01-10",- "update_date": "2022-02-02T06:45:11+01:00"- }- },- {- "pk": 126,- "model": "exercises.exercise",- "fields": {- "uuid": "283ad85ca8984a719abbc9cadd62b353",- "language": 2,- "exercise_base": 4,+ "exercise_base": 8,"description": "","name": "Needed for demo user","creation_date": "2022-01-10",