Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Update exercise image handling to update existing records instead of skipping

shihab47fd1f99f121
diff --git a/wger/exercises/sync.py b/wger/exercises/sync.py
index 1df4b6016..132011861 100644
--- a/wger/exercises/sync.py
+++ b/wger/exercises/sync.py
@@ -389,9 +389,18 @@ def download_exercise_images(
continue
try:
- ExerciseImage.objects.get(uuid=image_uuid)
- print_fn(' Image already present locally, skipping...')
- continue
+ image = ExerciseImage.objects.get(uuid=image_uuid)
+ print_fn(' Image already present locally, updating fields...')
+ image.exercise = exercise
+ image.is_main = image_data['is_main']
+ image.style = image_data['style']
+ image.license_id = image_data['license']
+ image.license_title = image_data['license_title']
+ image.license_object_url = image_data['license_object_url']
+ image.license_author = image_data['license_author']
+ image.license_author_url = image_data['license_author_url']
+ image.license_derivative_source_url = image_data['license_derivative_source_url']
+ image.save()
except ExerciseImage.DoesNotExist:
print_fn(' Image not found in local DB, creating now...')
retrieved_image = requests.get(image_data['image'], headers=headers)