Self hosted FLOSS fitness/workout, nutrition and weight tracker
Filter exercise translations by language over the API
Christopher Pruijsenbcd17173ddfa
diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.pyindex 73092bd72..364eb796f 100644--- a/wger/exercises/api/views.py+++ b/wger/exercises/api/views.py@@ -189,6 +189,7 @@ class ExerciseTranslationViewSet(ModelViewSet):'exercise','description','name',+ 'language',)def perform_create(self, serializer):diff --git a/wger/exercises/tests/test_exercise_translation.py b/wger/exercises/tests/test_exercise_translation.pyindex 69d2f7a76..e9f70f8bb 100644--- a/wger/exercises/tests/test_exercise_translation.py+++ b/wger/exercises/tests/test_exercise_translation.py@@ -98,6 +98,19 @@ class ExerciseTranslationApiTestCase(def get_resource_name(self):return 'exercise-translation'+ def test_get_overview_filter_by_language(self):+ """+ Filtering the overview by ``language`` only returns translations in+ that language.+ """+ response = self.client.get(self.url + '?language=1')++ self.assertEqual(response.status_code, status.HTTP_200_OK)+ self.assertEqual(+ {result['id'] for result in response.data['results']},+ set(Translation.objects.filter(language_id=1).values_list('id', flat=True)),+ )+class ExerciseInfoApiTestCase(api_base_test.BaseTestCase,