Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Skip exercises when no base could be loaded

Roland Geider12738b0d2257
diff --git a/wger/exercises/management/commands/sync-exercises.py b/wger/exercises/management/commands/sync-exercises.py
index 4b26a7585..300b7a1aa 100644
--- a/wger/exercises/management/commands/sync-exercises.py
+++ b/wger/exercises/management/commands/sync-exercises.py
@@ -169,6 +169,14 @@ class Command(BaseCommand):
exercise = Exercise.objects.get(uuid=exercise_uuid)
exercise.name = exercise_name
exercise.description = exercise_description
+
+ # Note: this should not happen and is an unnecessary workaround
+ # https://github.com/wger-project/wger/issues/840
+ if not exercise.exercise_base:
+ warning = f'Exercise {exercise.uuid} has no base, this should not happen!' \
+ f'Skipping...\n'
+ self.stdout.write(self.style.WARNING(warning))
+ continue
exercise.exercise_base.category_id = data['category']['id']
exercise.exercise_base.muscles.set(muscles)
exercise.exercise_base.muscles_secondary.set(muscles_sec)