Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Added language filter to exercisecomments API

Rashmi Kamatha9a99504faee
diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.py
index ceacdbbd7..38ad909b1 100644
--- a/wger/exercises/api/views.py
+++ b/wger/exercises/api/views.py
@@ -221,11 +221,22 @@ class ExerciseCommentViewSet(viewsets.ReadOnlyModelViewSet):
"""
API endpoint for exercise comment objects
"""
- queryset = ExerciseComment.objects.all()
serializer_class = ExerciseCommentSerializer
+
ordering_fields = '__all__'
- filterset_fields = ('comment',
- 'exercise')
+ filterset_fields = ('exercise',
+ 'comment'
+ )
+ """
+ Filter by language for exercise comments
+ """
+ def get_queryset(self):
+ qs = ExerciseComment.objects.all()
+ language = self.request.query_params.get('language', None)
+ if language:
+ exercises = Exercise.objects.filter(language=language)
+ qs = ExerciseComment.objects.filter(exercise__in=exercises)
+ return qs
class MuscleViewSet(viewsets.ReadOnlyModelViewSet):