Self hosted FLOSS fitness/workout, nutrition and weight tracker
Merge branch 'feature/exercise-crowdsourcing' into 1055-show-history
Roland Geidere27f279097b0
diff --cc requirements_dev.txtindex 7a125d641,8343910ba..60236bd97--- a/requirements_dev.txt+++ b/requirements_dev.txt@@@ -11,8 -11,11 +11,8 @@@ wheel==0.37.# for ingredient import script from OFFpymongo==4.1.1-# for ingredient import script from OFF-pymongo==3.12.1-# Development packages- coverage==6.3.3- django-debug-toolbar==3.4.0+ coverage==6.4.1+ django-debug-toolbar==3.5.0tblib==1.7.0isort==5.10.1diff --cc wger/exercises/api/views.pyindex c3204c063,158439c3d..9db7f26df--- a/wger/exercises/api/views.py+++ b/wger/exercises/api/views.py@@@ -144,19 -161,25 +161,40 @@@ class ExerciseTranslationViewSet(Create"""Save entry to activity stream"""++ obj_id = self.kwargs['pk']+ updated_object = Exercise.objects.get(id=obj_id)++ # Create a default history to diff against if there is none+ if updated_object:+ most_recent_history = updated_object.history.order_by('history_date').last()+ if most_recent_history is None:+ updated_object.save()++ super().perform_create(serializer)++ most_recent_history = updated_object.history.order_by('history_date').last()++++ # Don't allow to change the base or the language over the API+ if serializer.validated_data.get('exercise_base'):+ del serializer.validated_data['exercise_base']++ if serializer.validated_data.get('language'):+ del serializer.validated_data['language']++ # Clean the description HTML+ if serializer.validated_data.get('description'):+ serializer.validated_data['description'] = bleach.clean(+ serializer.validated_data['description'],+ tags=HTML_TAG_WHITELIST,+ attributes=HTML_ATTRIBUTES_WHITELIST,+ styles=HTML_STYLES_WHITELIST,+ strip=True+ )++ super().perform_update(serializer)++actstream_action.send(self.request.user,verb=StreamVerbs.UPDATED.value,