Self hosted FLOSS fitness/workout, nutrition and weight tracker
Correctly set data when creating a new exercise base
Roland Geider5bd8166f76d0
diff --git a/docs/changelog.rst b/docs/changelog.rstindex e351bd428..9f88db7e8 100644--- a/docs/changelog.rst+++ b/docs/changelog.rst@@ -48,7 +48,7 @@ Upgrade steps from 1.9:* `#368`_, `#379`_, `#426`_ (thanks `@austin-leung`_), `#499`_, `#505`_, `#504`_,`#511`_, `#516`_, `#522`_, `#554`_ and `#560`_ (thanks `@sandilsranasinghe`_),- `#564`_, `#565`_, `#615`_, `#560`_ (thanks `@bradsk88`_),+ `#564`_, `#565`_, `#615`_, `#560`_ (thanks `@bradsk88`_), `#636`_,🧰 Maintenance:@@ -119,6 +119,7 @@ Upgrade steps from 1.9:.. _#568: https://github.com/wger-project/wger/issues/568.. _#615: https://github.com/wger-project/wger/issues/615.. _#631: https://github.com/wger-project/wger/issues/631+.. _#636: https://github.com/wger-project/wger/issues/636diff --git a/wger/exercises/views/exercises.py b/wger/exercises/views/exercises.pyindex f03d97f4f..7a1389085 100644--- a/wger/exercises/views/exercises.py+++ b/wger/exercises/views/exercises.py@@ -301,6 +301,8 @@ class ExerciseAddView(ExercisesEditAddView, LoginRequiredMixin, CreateView):"""form.instance.language = load_language()form.instance.set_author(self.request)++ # Try retrieving a base exercise firstexisting = ExerciseBase.objects.filter(category=ExerciseCategory.objects.get(name=form.cleaned_data['category']))for elem in form.cleaned_data['equipment'].all():@@ -308,15 +310,16 @@ class ExerciseAddView(ExercisesEditAddView, LoginRequiredMixin, CreateView):for elem in form.cleaned_data['muscles'].all():existing = existing.filter(muscles=elem)for elem in form.cleaned_data['muscles_secondary'].all():- existing = existing.filter(equipment=elem)+ existing = existing.filter(muscles_secondary=elem)++ # Create a new exercise baseif not existing:- print(form.cleaned_data)- print('-------------------------')exercise_base = ExerciseBase.objects.create(- category=ExerciseCategory.objects.get(name=form.cleaned_data['category']),- license=License.objects.get(id=form.cleaned_data['license']),- license_author=License.objects.get(id=form.cleaned_data['license_author']),+ category=form.cleaned_data['category'],+ license=form.cleaned_data['license'],+ license_author=form.cleaned_data['license_author'])+exercise_base.equipment.set(form.cleaned_data['equipment'].all())exercise_base.muscles.set(form.cleaned_data['muscles'].all())exercise_base.muscles_secondary.set(form.cleaned_data['muscles_secondary'].all())