Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Move more logic out of generator.py and to own management commands

Roland Geider1d11f8e5c862
diff --git a/extras/dummy_generator/csv/measurement_categories.csv b/extras/dummy_generator/csv/measurement_categories.csv
deleted file mode 100644
index e7314fae0..000000000
--- a/extras/dummy_generator/csv/measurement_categories.csv
+++ /dev/null
@@ -1,9 +0,0 @@
-"Biceps","cm"
-"Body fat","%"
-"Smartness","IQ"
-"Hotness","°C"
-"Strength","KN"
-"Height","cm"
-"Facebook friends",""
-"Tonnes moved","T"
-"Weight of my dog","lb"
diff --git a/extras/dummy_generator/generator.py b/extras/dummy_generator/generator.py
index 99e5e729c..3d9131b46 100644
--- a/extras/dummy_generator/generator.py
+++ b/extras/dummy_generator/generator.py
@@ -36,28 +36,10 @@ django.setup()
from django.contrib.auth.models import User
# wger
-from wger.core.models import (
- DaysOfWeek,
-)
-from wger.exercises.models import Exercise
from wger.gym.models import (
Gym,
GymUserConfig,
)
-from wger.manager.models import (
- Day,
- Schedule,
- ScheduleStep,
- Set,
- Setting,
- Workout,
- WorkoutLog,
- WorkoutSession,
-)
-from wger.measurements.models import (
- Category,
- Measurement,
-)
from wger.weight.models import WeightEntry
parser = argparse.ArgumentParser(description='Data generator. Please consult the documentation')
@@ -81,19 +63,6 @@ user_parser.add_argument(
choices=['germany', 'ukraine', 'spain', 'usa']
)
-# Workout options
-workouts_parser = subparsers.add_parser('workouts', help='Create workouts')
-workouts_parser.add_argument(
- 'number_workouts',
- action='store',
- help='Number of workouts to create *per user*',
- type=int,
-)
-workouts_parser.add_argument(
- '--add-to-user',
- action='store',
- help='Add to the specified user-ID, not all existing users',
-)
# Gym options
gym_parser = subparsers.add_parser('gyms', help='Create gyms')
@@ -103,24 +72,7 @@ gym_parser.add_argument(
help='Number of gyms to create',
type=int,
)
-# Log options
-logs_parser = subparsers.add_parser('logs', help='Create logs')
-logs_parser.add_argument(
- 'number_logs',
- action='store',
- help='Number of logs to create per user and workout',
- type=int,
-)
-# Session options
-session_parser = subparsers.add_parser('sessions', help='Create sessions')
-session_parser.add_argument(
- 'impression_sessions',
- action='store',
- help='Impression for the sessions, default: random',
- default='random',
- choices=['random', 'good', 'neutral', 'bad']
-)
# Weight options
weight_parser = subparsers.add_parser('weight', help='Create weight entries')
@@ -143,57 +95,6 @@ weight_parser.add_argument(
default=80,
)
-# Measurement options
-measurement_parser = subparsers.add_parser('measurement', help='Create measurement entries')
-measurement_parser.add_argument(
- 'number_measurement',
- action='store',
- help='Number of measurement entries to create per user',
- type=int
-)
-measurement_parser.add_argument(
- '--add-to-user',
- action='store',
- help='Add to the specified user-ID, not all existing users',
-)
-
-# Nutrition options
-nutrition_parser = subparsers.add_parser(
- 'nutrition',
- help='Creates a meal plan',
-)
-nutrition_parser.add_argument(
- 'number_nutrition_plans',
- action='store',
- help='Number of meal plans to create',
- type=int,
-)
-nutrition_parser.add_argument(
- '--add-to-user',
- action='store',
- help='Add to the specified user-ID, not all existing users',
-)
-
-# Nutrition diary options
-nutrition_parser = subparsers.add_parser('nutrition-diary', help='Creates a meal plan')
-nutrition_parser.add_argument(
- 'number_nutrition_logs',
- action='store',
- help='Number of nutrition diary logs to create',
- type=int
-)
-nutrition_parser.add_argument(
- '--number-diary-dates',
- action='store',
- help='Number of dates in which to create logs (default: 30)',
- default=30,
- type=int
-)
-nutrition_parser.add_argument(
- '--add-to-user',
- action='store',
- help='Add to the specified user-ID, not all existing users',
-)
args = parser.parse_args()
# print(args)
@@ -300,176 +201,6 @@ if hasattr(args, 'number_gyms'):
# Bulk-create all the gyms
Gym.objects.bulk_create(gym_list)
-#
-# Workout generator
-#
-if hasattr(args, 'number_workouts'):
- print("** Generating {0} workouts per user".format(args.number_workouts))
-
- if args.add_to_user:
- userlist = [User.objects.get(pk=args.add_to_user)]
- else:
- userlist = User.objects.all()
-
- for user in userlist:
- print(' - generating for {0}'.format(user.username))
-
- # Workouts
- for i in range(1, args.number_workouts):
-
- uid = str(uuid.uuid4()).split('-')
- start_date = datetime.date.today() - datetime.timedelta(days=random.randint(0, 100))
- workout = Workout(
- user=user,
- name='Dummy workout - {0}'.format(uid[1]),
- creation_date=start_date,
- )
- workout.save()
-
- # Select a random number of workout days
- nr_of_days = random.randint(1, 5)
- day_list = [i for i in range(1, 8)]
- random.shuffle(day_list)
-
- # Load all exercises to a list
- exercise_list = [i for i in Exercise.objects.filter(language_id=2)]
-
- for day in day_list[0:nr_of_days]:
- uid = str(uuid.uuid4()).split('-')
- weekday = DaysOfWeek.objects.get(pk=day)
-
- day = Day(training=workout, description='Dummy day - {0}'.format(uid[0]))
- day.save()
- day.day.add(weekday)
-
- # Select a random number of exercises
- nr_of_exercises = random.randint(3, 10)
- random.shuffle(exercise_list)
- day_exercises = exercise_list[0:nr_of_exercises]
- order = 1
- for exercise in day_exercises:
- reps = random.choice([1, 3, 5, 8, 10, 12, 15])
- sets = random.randint(2, 4)
-
- day_set = Set(exerciseday=day, sets=sets, order=order)
- day_set.save()
-
- setting = Setting(
- set=day_set,
- exercise_base=exercise.exercise_base,
- reps=reps,
- order=order,
- )
- setting.save()
- order += 1
-
- # Schedules
- nr_of_schedules = random.randint(1, 5)
- user_workouts = [i for i in Workout.objects.filter(user=user)]
- for i in range(0, nr_of_schedules):
- uid = str(uuid.uuid4()).split('-')
- start_date = datetime.date.today() - datetime.timedelta(days=random.randint(0, 30))
-
- random.shuffle(user_workouts)
-
- schedule = Schedule()
- schedule.user = user
- schedule.name = 'Dummy schedule - {0}'.format(uid[1])
- schedule.start_date = start_date
- schedule.is_active = True
- schedule.is_loop = True
- schedule.save()
-
- nr_of_steps = random.randint(1, len(user_workouts))
- order = 1
- for j in range(1, nr_of_steps):
- step = ScheduleStep()
- step.schedule = schedule
- step.workout = workout
- step.duration = random.randint(1, 4)
- step.order = order
- step.save()
-
- order += 1
-
-#
-# Log generator
-#
-if hasattr(args, 'number_logs'):
- print("** Generating {0} logs".format(args.number_logs))
-
- for user in User.objects.all():
- weight_log = []
- print(' - generating for {0}'.format(user.username))
-
- # Create a log for each workout day, set, setting, reps, weight, date
- for workout in Workout.objects.filter(user=user):
- for day in workout.day_set.all():
- for set in day.set_set.all():
- for setting in set.setting_set.all():
- for reps in (8, 10, 12):
- for i in range(1, args.number_logs):
- date = datetime.date.today() - datetime.timedelta(weeks=i)
- log = WorkoutLog(
- user=user,
- exercise_base=setting.exercise_base,
- workout=workout,
- reps=reps,
- weight=50 - reps + random.randint(1, 10),
- date=date
- )
- weight_log.append(log)
-
- # Bulk-create the logs
- WorkoutLog.objects.bulk_create(weight_log)
-
-#
-# Session generator
-#
-if hasattr(args, 'impression_sessions'):
- print("** Generating workout sessions")
-
- for user in User.objects.all():
- session_list = []
- print(' - generating for {0}'.format(user.username))
-
- for date in WorkoutLog.objects.filter(user=user).dates('date', 'day'):
-
- # Only process for dates for which there isn't already a session
- if not WorkoutSession.objects.filter(user=user, date=date).exists():
-
- workout = WorkoutLog.objects.filter(user=user, date=date).first().workout
- start = datetime.time(hour=random.randint(8, 20), minute=random.randint(0, 59))
- end = datetime.datetime.combine(datetime.date.today(), start) \
- + datetime.timedelta(minutes=random.randint(40, 120))
- end = datetime.time(hour=end.hour, minute=end.minute)
-
- session = WorkoutSession()
- session.date = date
- session.user = user
- session.time_start = start
- session.time_end = end
- session.workout = workout
-
- if args.impression_sessions == 'good':
- session.impression = WorkoutSession.IMPRESSION_GOOD
- elif args.impression_sessions == 'neutral':
- session.impression = WorkoutSession.IMPRESSION_NEUTRAL
- elif args.impression_sessions == 'bad':
- session.impression = WorkoutSession.IMPRESSION_BAD
- else:
- session.impression = random.choice(
- [
- WorkoutSession.IMPRESSION_GOOD,
- WorkoutSession.IMPRESSION_NEUTRAL,
- WorkoutSession.IMPRESSION_BAD,
- ]
- )
-
- session_list.append(session)
-
- # Bulk-create the sessions
- WorkoutSession.objects.bulk_create(session_list)
#
# Weight entry generator
@@ -503,55 +234,6 @@ if hasattr(args, 'number_weight'):
# Bulk-create the weight entries
WeightEntry.objects.bulk_create(new_entries)
-#
-# Measurement entry generator
-#
-if hasattr(args, 'number_measurement'):
- print("** Generating {0} measurement entries per user".format(args.number_measurement))
-
- # Load units
- units = []
- with open(os.path.join('csv', 'measurement_categories.csv')) as category_file:
- category_reader = csv.reader(category_file)
- for row in category_reader:
- units.append({'name': row[0], 'unit': row[1]})
-
- # User list
- if args.add_to_user:
- userlist = [User.objects.get(pk=args.add_to_user)]
- else:
- userlist = User.objects.all()
-
- new_entries = []
- for user in userlist:
- BASE_VALUE = random.randint(80, 100)
- print(' - generating measurements for {0}'.format(user.username))
- existing_entries = [i.date for i in Measurement.objects.filter(category__user=user)]
-
- for measurement_cat in random.choices(units, k=4):
- print(measurement_cat)
-
- cat = Category(
- name=measurement_cat['name'],
- unit=measurement_cat['unit'],
- user=user,
- )
- cat.save()
-
- for i in range(1, args.number_measurement):
- creation_date = datetime.date.today() - datetime.timedelta(days=i)
-
- if creation_date not in existing_entries:
- measurement = Measurement(
- category=cat,
- value=BASE_VALUE + 0.5 * i + random.randint(-20, 10),
- date=creation_date,
- )
- new_entries.append(measurement)
-
- # Bulk-create the entries
- Measurement.objects.bulk_create(new_entries)
-
#
# Nutrition Generator
#
diff --git a/wger/manager/management/commands/dummy-generator-workout-diary.py b/wger/manager/management/commands/dummy-generator-workout-diary.py
new file mode 100644
index 000000000..553b18077
--- /dev/null
+++ b/wger/manager/management/commands/dummy-generator-workout-diary.py
@@ -0,0 +1,110 @@
+# This file is part of wger Workout Manager.
+#
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+
+# Standard Library
+import datetime
+import logging
+import random
+import uuid
+from random import (
+ choice,
+ randint,
+)
+from uuid import uuid4
+
+# Django
+from django.contrib.auth.models import User
+from django.core.management.base import BaseCommand
+from django.utils import timezone
+
+# wger
+from wger.core.models import (
+ DaysOfWeek,
+ Language,
+)
+from wger.exercises.models import Exercise
+from wger.manager.models import (
+ Day,
+ Set,
+ Setting,
+ Workout,
+ WorkoutLog,
+)
+from wger.nutrition.models import (
+ Ingredient,
+ LogItem,
+ Meal,
+ MealItem,
+ NutritionPlan,
+)
+
+logger = logging.getLogger(__name__)
+
+
+class Command(BaseCommand):
+ """
+ Dummy generator for workout diary entries
+ """
+
+ help = 'Dummy generator for workout diary entries'
+
+ def add_arguments(self, parser):
+
+ parser.add_argument(
+ '--diary-entries',
+ action='store',
+ default=30,
+ dest='nr_diary_entries',
+ type=int,
+ help='The number of workout logs to create per day (default: 30)'
+ )
+ parser.add_argument(
+ '--user-id',
+ action='store',
+ dest='user_id',
+ type=int,
+ help='Add only to the specified user-ID (default: all users)',
+ )
+
+ def handle(self, **options):
+ self.stdout.write(f"** Generating {options['nr_diary_entries']} dummy diary entries")
+
+ users = [User.objects.get(pk=options['user_id'])] \
+ if options['user_id'] \
+ else User.objects.all()
+
+ weight_log = []
+ for user in users:
+ self.stdout.write(f'- processing user {user.username}')
+
+ # Create a log for each workout day, set, setting, reps, weight, date
+ for workout in Workout.objects.filter(user=user):
+ for day in workout.day_set.all():
+ for workout_set in day.set_set.all():
+ for setting in workout_set.setting_set.all():
+ for reps in (8, 10, 12):
+ for i in range(1, options['nr_diary_entries']):
+ date = datetime.date.today() - datetime.timedelta(weeks=i)
+ log = WorkoutLog(
+ user=user,
+ exercise_base=setting.exercise_base,
+ workout=workout,
+ reps=reps,
+ weight=50 - reps + random.randint(1, 10),
+ date=date
+ )
+ weight_log.append(log)
+
+ # Bulk-create the logs
+ WorkoutLog.objects.bulk_create(weight_log)
diff --git a/wger/manager/management/commands/dummy-generator-workout-plans.py b/wger/manager/management/commands/dummy-generator-workout-plans.py
new file mode 100644
index 000000000..7cfddecd4
--- /dev/null
+++ b/wger/manager/management/commands/dummy-generator-workout-plans.py
@@ -0,0 +1,134 @@
+# This file is part of wger Workout Manager.
+#
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+
+# Standard Library
+import datetime
+import logging
+import random
+import uuid
+
+# Django
+from django.contrib.auth.models import User
+from django.core.management.base import BaseCommand
+
+# wger
+from wger.core.models import DaysOfWeek
+from wger.exercises.models import Exercise
+from wger.manager.models import (
+ Day,
+ Set,
+ Setting,
+ Workout,
+)
+
+logger = logging.getLogger(__name__)
+
+
+class Command(BaseCommand):
+ """
+ Dummy generator for workout plans
+ """
+
+ help = 'Dummy generator for workout plans'
+
+ def add_arguments(self, parser):
+
+ parser.add_argument(
+ '--plans',
+ action='store',
+ default=10,
+ dest='nr_plans',
+ type=int,
+ help='The number of workout plans to create per user (default: 10)'
+ )
+ parser.add_argument(
+ '--diary-entries',
+ action='store',
+ default=30,
+ dest='nr_diary_entries',
+ type=int,
+ help='The number of workout logs to create per day (default: 30)'
+ )
+ parser.add_argument(
+ '--user-id',
+ action='store',
+ dest='user_id',
+ type=int,
+ help='Add only to the specified user-ID (default: all users)',
+ )
+
+ def handle(self, **options):
+ self.stdout.write(f"** Generating {options['nr_plans']} dummy workout plan(s) per user")
+
+ users = [User.objects.get(pk=options['user_id'])] \
+ if options['user_id'] \
+ else User.objects.all()
+
+ for user in users:
+ self.stdout.write(f'- processing user {user.username}')
+
+ # Add plan
+ for _ in range(0, options['nr_plans']):
+ uid = str(uuid.uuid4()).split('-')
+ start_date = datetime.date.today() - datetime.timedelta(days=random.randint(0, 100))
+ workout = Workout(
+ user=user,
+ name='Dummy workout - {0}'.format(uid[1]),
+ creation_date=start_date,
+ )
+ workout.save()
+
+ # Select a random number of workout days
+ nr_of_days = random.randint(1, 5)
+ day_list = [i for i in range(1, 8)]
+ random.shuffle(day_list)
+
+ # Load all exercises to a list
+ exercise_list = [i for i in Exercise.objects.filter(language_id=2)]
+
+ for day in day_list[0:nr_of_days]:
+ uid = str(uuid.uuid4()).split('-')
+ weekday = DaysOfWeek.objects.get(pk=day)
+
+ day = Day(
+ training=workout,
+ description='Dummy day - {0}'.format(uid[0]),
+ )
+ day.save()
+ day.day.add(weekday)
+
+ # Select a random number of exercises
+ nr_of_exercises = random.randint(3, 10)
+ random.shuffle(exercise_list)
+ day_exercises = exercise_list[0:nr_of_exercises]
+ order = 1
+ for exercise in day_exercises:
+ reps = random.choice([1, 3, 5, 8, 10, 12, 15])
+ sets = random.randint(2, 4)
+
+ day_set = Set(
+ exerciseday=day,
+ sets=sets,
+ order=order,
+ )
+ day_set.save()
+
+ setting = Setting(
+ set=day_set,
+ exercise_base=exercise.exercise_base,
+ reps=reps,
+ order=order,
+ )
+ setting.save()
+ order += 1
diff --git a/wger/measurements/management/__init__.py b/wger/measurements/management/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/wger/measurements/management/commands/__init__.py b/wger/measurements/management/commands/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/wger/measurements/management/commands/dummy-generator-measurement-categories.py b/wger/measurements/management/commands/dummy-generator-measurement-categories.py
new file mode 100644
index 000000000..d661c0a27
--- /dev/null
+++ b/wger/measurements/management/commands/dummy-generator-measurement-categories.py
@@ -0,0 +1,119 @@
+# This file is part of wger Workout Manager.
+#
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+
+# Standard Library
+import logging
+import random
+import sys
+
+# Django
+from django.contrib.auth.models import User
+from django.core.management.base import BaseCommand
+
+# wger
+from wger.measurements.models import Category
+
+logger = logging.getLogger(__name__)
+
+
+class Command(BaseCommand):
+ """
+ Dummy generator for measurement categories
+ """
+ categories = [
+ {
+ "name": "Biceps",
+ "unit": "cm"
+ },
+ {
+ "name": "Quads",
+ "unit": "cm"
+ },
+ {
+ "name": "Body fat",
+ "unit": "%"
+ },
+ {
+ "name": "Smartness",
+ "unit": "IQ"
+ },
+ {
+ "name": "Hotness",
+ "unit": "°C"
+ },
+ {
+ "name": "Strength",
+ "unit": "KN"
+ },
+ {
+ "name": "Height",
+ "unit": "cm"
+ },
+ {
+ "name": "Facebook friends",
+ "unit": ""
+ },
+ {
+ "name": "Tonnes moved",
+ "unit": "T"
+ },
+ {
+ "name": "Weight of my dog",
+ "unit": "lb"
+ },
+ ]
+
+ help = 'Dummy generator for measurement categories'
+
+ def add_arguments(self, parser):
+
+ parser.add_argument(
+ '--nr-categories',
+ action='store',
+ default=5,
+ dest='nr_categories',
+ type=int,
+ help='The number of measurement categories to create per user (default: 5, max: 10)'
+ )
+ parser.add_argument(
+ '--user-id',
+ action='store',
+ dest='user_id',
+ type=int,
+ help='Add only to the specified user-ID (default: all users)',
+ )
+
+ def handle(self, **options):
+ self.stdout.write(
+ f"** Generating {options['nr_categories']} dummy measurement categories per user"
+ )
+
+ users = [User.objects.get(pk=options['user_id'])] \
+ if options['user_id'] \
+ else User.objects.all()
+
+ if options['nr_categories'] > 10:
+ print('10 Categories is the maximum allowed')
+ sys.exit()
+
+ for user in users:
+ self.stdout.write(f'- processing user {user.username}')
+
+ for measurement_cat in random.choices(self.categories, k=options['nr_categories']):
+ cat = Category(
+ name=measurement_cat['name'],
+ unit=measurement_cat['unit'],
+ user=user,
+ )
+ cat.save()
diff --git a/wger/measurements/management/commands/dummy-generator-measurements.py b/wger/measurements/management/commands/dummy-generator-measurements.py
new file mode 100644
index 000000000..4aad86bc3
--- /dev/null
+++ b/wger/measurements/management/commands/dummy-generator-measurements.py
@@ -0,0 +1,94 @@
+# This file is part of wger Workout Manager.
+#
+# 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 General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+
+# Standard Library
+import datetime
+import logging
+import random
+
+# Django
+from django.contrib.auth.models import User
+from django.core.management.base import BaseCommand
+
+# wger
+from wger.measurements.models import (
+ Category,
+ Measurement,
+)
+
+logger = logging.getLogger(__name__)
+
+
+class Command(BaseCommand):
+ """
+ Dummy generator for measurement entries
+ """
+
+ help = 'Dummy generator for measurement entries'
+
+ def add_arguments(self, parser):
+
+ parser.add_argument(
+ '--nr-measurements',
+ action='store',
+ default=40,
+ dest='nr_measurements',
+ type=int,
+ help='The number of measurement entries per category (default: 40)'
+ )
+ parser.add_argument(
+ '--category-id',
+ action='store',
+ dest='category_id',
+ type=int,
+ help='Add only to the specified measurement category ID (default: all)',
+ )
+ parser.add_argument(
+ '--user-id',
+ action='store',
+ dest='user_id',
+ type=int,
+ help='Add only to the specified user-ID (default: all users)',
+ )
+
+ def handle(self, **options):
+ self.stdout.write(f"** Generating {options['nr_measurements']} dummy measurements per user")
+
+ users = [User.objects.get(pk=options['user_id'])] \
+ if options['user_id'] \
+ else User.objects.all()
+
+ categories = [Category.objects.get(pk=options['category_id'])] \
+ if options['category_id'] \
+ else Category.objects.all()
+
+ new_entries = []
+ for user in users:
+ self.stdout.write(f'- processing user {user.username}')
+
+ for category in categories:
+ base_value = random.randint(10, 100)
+
+ for i in range(1, options['nr_measurements']):
+ date = datetime.date.today() - datetime.timedelta(days=2 * i)
+ if not Measurement.objects.filter(category=category, date=date).exists():
+ measurement = Measurement(
+ category=category,
+ value=base_value + 0.5 * i + random.randint(-20, 10),
+ date=date,
+ )
+ new_entries.append(measurement)
+
+ # Bulk-create the entries
+ Measurement.objects.bulk_create(new_entries)
diff --git a/wger/measurements/models/category.py b/wger/measurements/models/category.py
index 3c2d21e31..5e44e313a 100644
--- a/wger/measurements/models/category.py
+++ b/wger/measurements/models/category.py
@@ -1,19 +1,3 @@
-# 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/>.
-
# This file is part of wger Workout Manager.
#
# wger Workout Manager is free software: you can redistribute it and/or modify
diff --git a/wger/measurements/models/measurement.py b/wger/measurements/models/measurement.py
index eeb8c11e8..5a181a307 100644
--- a/wger/measurements/models/measurement.py
+++ b/wger/measurements/models/measurement.py
@@ -1,19 +1,3 @@
-# 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/>.
-
# This file is part of wger Workout Manager.
#
# wger Workout Manager is free software: you can redistribute it and/or modify
diff --git a/wger/nutrition/management/commands/dummy-generator-nutrition.py b/wger/nutrition/management/commands/dummy-generator-nutrition.py
index 9c2b37342..2dd4249e6 100644
--- a/wger/nutrition/management/commands/dummy-generator-nutrition.py
+++ b/wger/nutrition/management/commands/dummy-generator-nutrition.py
@@ -42,13 +42,10 @@ logger = logging.getLogger(__name__)
class Command(BaseCommand):
"""
- One off script
-
- This is intended to download all images from Open Food Facts for the all
- currently used ingredients
+ Dummy generator for nutritional plans
"""
- help = 'Download images of all Open Food Facts ingredients that are used in a nutritional plan'
+ help = 'Dummy generator for nutritional plans'
def add_arguments(self, parser):