Self hosted FLOSS fitness/workout, nutrition and weight tracker
Rename exercise model to translation
Roland Geider385df1d64f8a
diff --git a/wger/core/fixtures/groups.json b/wger/core/fixtures/groups.jsonindex 96e3c6ca5..d867acefe 100644--- a/wger/core/fixtures/groups.json+++ b/wger/core/fixtures/groups.json@@ -1,565 +1,565 @@[- {- "fields": {- "name": "admin",- "permissions": [- [- "add_gymconfig",- "config",- "gymconfig"- ],- [- "change_gymconfig",- "config",- "gymconfig"- ],- [- "delete_gymconfig",- "config",- "gymconfig"- ],- [- "add_language",- "core",- "language"- ],- [- "change_language",- "core",- "language"- ],- [- "delete_language",- "core",- "language"- ],- [- "add_license",- "core",- "license"- ],- [- "change_license",- "core",- "license"- ],- [- "delete_license",- "core",- "license"- ],- [- "add_repetitionunit",- "core",- "repetitionunit"- ],- [- "change_repetitionunit",- "core",- "repetitionunit"- ],- [- "delete_repetitionunit",- "core",- "repetitionunit"- ],- [- "add_weightunit",- "core",- "weightunit"- ],- [- "change_weightunit",- "core",- "weightunit"- ],- [- "delete_weightunit",- "core",- "weightunit"- ],- [- "add_equipment",- "exercises",- "equipment"- ],- [- "change_equipment",- "exercises",- "equipment"- ],- [- "delete_equipment",- "exercises",- "equipment"- ],- [- "add_exercise",- "exercises",- "exercise"- ],- [- "change_exercise",- "exercises",- "exercise"- ],- [- "delete_exercise",- "exercises",- "exercise"- ],- [- "add_exercisecategory",- "exercises",- "exercisecategory"- ],- [- "change_exercisecategory",- "exercises",- "exercisecategory"- ],- [- "delete_exercisecategory",- "exercises",- "exercisecategory"- ],- [- "add_exercisecomment",- "exercises",- "exercisecomment"- ],- [- "change_exercisecomment",- "exercises",- "exercisecomment"- ],- [- "delete_exercisecomment",- "exercises",- "exercisecomment"- ],- [- "add_exerciseimage",- "exercises",- "exerciseimage"- ],- [- "change_exerciseimage",- "exercises",- "exerciseimage"- ],- [- "delete_exerciseimage",- "exercises",- "exerciseimage"- ],- [- "add_exercisevideo",- "exercises",- "exercisevideo"- ],- [- "change_exercisevideo",- "exercises",- "exercisevideo"- ],- [- "delete_exercisevideo",- "exercises",- "exercisevideo"- ],- [- "add_muscle",- "exercises",- "muscle"- ],- [- "change_muscle",- "exercises",- "muscle"- ],- [- "delete_muscle",- "exercises",- "muscle"- ],- [- "add_gym",- "gym",- "gym"- ],- [- "change_gym",- "gym",- "gym"- ],- [- "delete_gym",- "gym",- "gym"- ],- [- "gym_trainer",- "gym",- "gym"- ],- [- "manage_gym",- "gym",- "gym"- ],- [- "manage_gyms",- "gym",- "gym"- ],- [- "change_gymadminconfig",- "gym",- "gymadminconfig"- ],- [- "change_gymconfig",- "gym",- "gymconfig"- ],- [- "change_gymuserconfig",- "gym",- "gymuserconfig"- ],- [- "add_ingredient",- "nutrition",- "ingredient"- ],- [- "change_ingredient",- "nutrition",- "ingredient"- ],- [- "delete_ingredient",- "nutrition",- "ingredient"- ],- [- "add_ingredientweightunit",- "nutrition",- "ingredientweightunit"- ],- [- "change_ingredientweightunit",- "nutrition",- "ingredientweightunit"- ],- [- "delete_ingredientweightunit",- "nutrition",- "ingredientweightunit"- ],- [- "add_weightunit",- "nutrition",- "weightunit"- ],- [- "change_weightunit",- "nutrition",- "weightunit"- ],- [- "delete_weightunit",- "nutrition",- "weightunit"- ]- ]- },- "model": "auth.group",- "pk": 1+ {+ "fields": {+ "name": "admin",+ "permissions": [+ [+ "add_gymconfig",+ "config",+ "gymconfig"+ ],+ [+ "change_gymconfig",+ "config",+ "gymconfig"+ ],+ [+ "delete_gymconfig",+ "config",+ "gymconfig"+ ],+ [+ "add_language",+ "core",+ "language"+ ],+ [+ "change_language",+ "core",+ "language"+ ],+ [+ "delete_language",+ "core",+ "language"+ ],+ [+ "add_license",+ "core",+ "license"+ ],+ [+ "change_license",+ "core",+ "license"+ ],+ [+ "delete_license",+ "core",+ "license"+ ],+ [+ "add_repetitionunit",+ "core",+ "repetitionunit"+ ],+ [+ "change_repetitionunit",+ "core",+ "repetitionunit"+ ],+ [+ "delete_repetitionunit",+ "core",+ "repetitionunit"+ ],+ [+ "add_weightunit",+ "core",+ "weightunit"+ ],+ [+ "change_weightunit",+ "core",+ "weightunit"+ ],+ [+ "delete_weightunit",+ "core",+ "weightunit"+ ],+ [+ "add_equipment",+ "exercises",+ "equipment"+ ],+ [+ "change_equipment",+ "exercises",+ "equipment"+ ],+ [+ "delete_equipment",+ "exercises",+ "equipment"+ ],+ [+ "add_translation",+ "exercises",+ "translation"+ ],+ [+ "change_translation",+ "exercises",+ "translation"+ ],+ [+ "delete_translation",+ "exercises",+ "translation"+ ],+ [+ "add_exercisecategory",+ "exercises",+ "exercisecategory"+ ],+ [+ "change_exercisecategory",+ "exercises",+ "exercisecategory"+ ],+ [+ "delete_exercisecategory",+ "exercises",+ "exercisecategory"+ ],+ [+ "add_exercisecomment",+ "exercises",+ "exercisecomment"+ ],+ [+ "change_exercisecomment",+ "exercises",+ "exercisecomment"+ ],+ [+ "delete_exercisecomment",+ "exercises",+ "exercisecomment"+ ],+ [+ "add_exerciseimage",+ "exercises",+ "exerciseimage"+ ],+ [+ "change_exerciseimage",+ "exercises",+ "exerciseimage"+ ],+ [+ "delete_exerciseimage",+ "exercises",+ "exerciseimage"+ ],+ [+ "add_exercisevideo",+ "exercises",+ "exercisevideo"+ ],+ [+ "change_exercisevideo",+ "exercises",+ "exercisevideo"+ ],+ [+ "delete_exercisevideo",+ "exercises",+ "exercisevideo"+ ],+ [+ "add_muscle",+ "exercises",+ "muscle"+ ],+ [+ "change_muscle",+ "exercises",+ "muscle"+ ],+ [+ "delete_muscle",+ "exercises",+ "muscle"+ ],+ [+ "add_gym",+ "gym",+ "gym"+ ],+ [+ "change_gym",+ "gym",+ "gym"+ ],+ [+ "delete_gym",+ "gym",+ "gym"+ ],+ [+ "gym_trainer",+ "gym",+ "gym"+ ],+ [+ "manage_gym",+ "gym",+ "gym"+ ],+ [+ "manage_gyms",+ "gym",+ "gym"+ ],+ [+ "change_gymadminconfig",+ "gym",+ "gymadminconfig"+ ],+ [+ "change_gymconfig",+ "gym",+ "gymconfig"+ ],+ [+ "change_gymuserconfig",+ "gym",+ "gymuserconfig"+ ],+ [+ "add_ingredient",+ "nutrition",+ "ingredient"+ ],+ [+ "change_ingredient",+ "nutrition",+ "ingredient"+ ],+ [+ "delete_ingredient",+ "nutrition",+ "ingredient"+ ],+ [+ "add_ingredientweightunit",+ "nutrition",+ "ingredientweightunit"+ ],+ [+ "change_ingredientweightunit",+ "nutrition",+ "ingredientweightunit"+ ],+ [+ "delete_ingredientweightunit",+ "nutrition",+ "ingredientweightunit"+ ],+ [+ "add_weightunit",+ "nutrition",+ "weightunit"+ ],+ [+ "change_weightunit",+ "nutrition",+ "weightunit"+ ],+ [+ "delete_weightunit",+ "nutrition",+ "weightunit"+ ]+ ]},- {- "fields": {- "name": "general_gym_manager",- "permissions": [- [- "change_gymconfig",- "config",- "gymconfig"- ],- [- "add_gym",- "gym",- "gym"- ],- [- "change_gym",- "gym",- "gym"- ],- [- "delete_gym",- "gym",- "gym"- ],- [- "manage_gyms",- "gym",- "gym"- ],- [- "change_gymadminconfig",- "gym",- "gymadminconfig"- ]- ]- },- "model": "auth.group",- "pk": 2+ "model": "auth.group",+ "pk": 1+ },+ {+ "fields": {+ "name": "general_gym_manager",+ "permissions": [+ [+ "change_gymconfig",+ "config",+ "gymconfig"+ ],+ [+ "add_gym",+ "gym",+ "gym"+ ],+ [+ "change_gym",+ "gym",+ "gym"+ ],+ [+ "delete_gym",+ "gym",+ "gym"+ ],+ [+ "manage_gyms",+ "gym",+ "gym"+ ],+ [+ "change_gymadminconfig",+ "gym",+ "gymadminconfig"+ ]+ ]},- {- "fields": {- "name": "gym_manager",- "permissions": [- [- "add_log",- "mailer",- "log"- ],- [- "change_log",- "mailer",- "log"- ],- [- "add_contract",- "gym",- "contract"- ],- [- "change_contract",- "gym",- "contract"- ],- [- "delete_contract",- "gym",- "contract"- ],- [- "add_contractoption",- "gym",- "contractoption"- ],- [- "change_contractoption",- "gym",- "contractoption"- ],- [- "delete_contractoption",- "gym",- "contractoption"- ],- [- "add_contracttype",- "gym",- "contracttype"- ],- [- "change_contracttype",- "gym",- "contracttype"- ],- [- "delete_contracttype",- "gym",- "contracttype"- ],- [- "change_gym",- "gym",- "gym"- ],- [- "manage_gym",- "gym",- "gym"- ],- [- "change_gymadminconfig",- "gym",- "gymadminconfig"- ],- [- "change_gymconfig",- "gym",- "gymconfig"- ]- ]- },- "model": "auth.group",- "pk": 3+ "model": "auth.group",+ "pk": 2+ },+ {+ "fields": {+ "name": "gym_manager",+ "permissions": [+ [+ "add_log",+ "mailer",+ "log"+ ],+ [+ "change_log",+ "mailer",+ "log"+ ],+ [+ "add_contract",+ "gym",+ "contract"+ ],+ [+ "change_contract",+ "gym",+ "contract"+ ],+ [+ "delete_contract",+ "gym",+ "contract"+ ],+ [+ "add_contractoption",+ "gym",+ "contractoption"+ ],+ [+ "change_contractoption",+ "gym",+ "contractoption"+ ],+ [+ "delete_contractoption",+ "gym",+ "contractoption"+ ],+ [+ "add_contracttype",+ "gym",+ "contracttype"+ ],+ [+ "change_contracttype",+ "gym",+ "contracttype"+ ],+ [+ "delete_contracttype",+ "gym",+ "contracttype"+ ],+ [+ "change_gym",+ "gym",+ "gym"+ ],+ [+ "manage_gym",+ "gym",+ "gym"+ ],+ [+ "change_gymadminconfig",+ "gym",+ "gymadminconfig"+ ],+ [+ "change_gymconfig",+ "gym",+ "gymconfig"+ ]+ ]},- {- "fields": {- "name": "gym_trainer",- "permissions": [- [- "add_adminusernote",- "gym",- "adminusernote"- ],- [- "change_adminusernote",- "gym",- "adminusernote"- ],- [- "delete_adminusernote",- "gym",- "adminusernote"- ],- [- "gym_trainer",- "gym",- "gym"- ],- [- "change_gymadminconfig",- "gym",- "gymadminconfig"- ],- [- "change_gymuserconfig",- "gym",- "gymuserconfig"- ],- [- "add_userdocument",- "gym",- "userdocument"- ],- [- "change_userdocument",- "gym",- "userdocument"- ],- [- "delete_userdocument",- "gym",- "userdocument"- ]- ]- },- "model": "auth.group",- "pk": 4+ "model": "auth.group",+ "pk": 3+ },+ {+ "fields": {+ "name": "gym_trainer",+ "permissions": [+ [+ "add_adminusernote",+ "gym",+ "adminusernote"+ ],+ [+ "change_adminusernote",+ "gym",+ "adminusernote"+ ],+ [+ "delete_adminusernote",+ "gym",+ "adminusernote"+ ],+ [+ "gym_trainer",+ "gym",+ "gym"+ ],+ [+ "change_gymadminconfig",+ "gym",+ "gymadminconfig"+ ],+ [+ "change_gymuserconfig",+ "gym",+ "gymuserconfig"+ ],+ [+ "add_userdocument",+ "gym",+ "userdocument"+ ],+ [+ "change_userdocument",+ "gym",+ "userdocument"+ ],+ [+ "delete_userdocument",+ "gym",+ "userdocument"+ ]+ ]},- {- "fields": {- "name": "gym_member",- "permissions": []- },- "model": "auth.group",- "pk": 5+ "model": "auth.group",+ "pk": 4+ },+ {+ "fields": {+ "name": "gym_member",+ "permissions": []},- {- "fields": {- "name": "exercises_editor",- "permissions": [- [- "add_equipment",- "exercises",- "equipment"- ],- [- "change_equipment",- "exercises",- "equipment"- ],- [- "delete_equipment",- "exercises",- "equipment"- ],- [- "add_exercise",- "exercises",- "exercise"- ],- [- "change_exercise",- "exercises",- "exercise"- ],- [- "delete_exercise",- "exercises",- "exercise"- ],- [- "add_exercisecategory",- "exercises",- "exercisecategory"- ],- [- "change_exercisecategory",- "exercises",- "exercisecategory"- ],- [- "delete_exercisecategory",- "exercises",- "exercisecategory"- ],- [- "add_exercisecomment",- "exercises",- "exercisecomment"- ],- [- "change_exercisecomment",- "exercises",- "exercisecomment"- ],- [- "delete_exercisecomment",- "exercises",- "exercisecomment"- ],- [- "add_exerciseimage",- "exercises",- "exerciseimage"- ],- [- "change_exerciseimage",- "exercises",- "exerciseimage"- ],- [- "delete_exerciseimage",- "exercises",- "exerciseimage"- ],- [- "add_muscle",- "exercises",- "muscle"- ],- [- "change_muscle",- "exercises",- "muscle"- ],- [- "delete_muscle",- "exercises",- "muscle"- ]- ]- },- "model": "auth.group",- "pk": 6- }+ "model": "auth.group",+ "pk": 5+ },+ {+ "fields": {+ "name": "exercises_editor",+ "permissions": [+ [+ "add_equipment",+ "exercises",+ "equipment"+ ],+ [+ "change_equipment",+ "exercises",+ "equipment"+ ],+ [+ "delete_equipment",+ "exercises",+ "equipment"+ ],+ [+ "add_translation",+ "exercises",+ "translation"+ ],+ [+ "change_translation",+ "exercises",+ "translation"+ ],+ [+ "delete_translation",+ "exercises",+ "translation"+ ],+ [+ "add_exercisecategory",+ "exercises",+ "exercisecategory"+ ],+ [+ "change_exercisecategory",+ "exercises",+ "exercisecategory"+ ],+ [+ "delete_exercisecategory",+ "exercises",+ "exercisecategory"+ ],+ [+ "add_exercisecomment",+ "exercises",+ "exercisecomment"+ ],+ [+ "change_exercisecomment",+ "exercises",+ "exercisecomment"+ ],+ [+ "delete_exercisecomment",+ "exercises",+ "exercisecomment"+ ],+ [+ "add_exerciseimage",+ "exercises",+ "exerciseimage"+ ],+ [+ "change_exerciseimage",+ "exercises",+ "exerciseimage"+ ],+ [+ "delete_exerciseimage",+ "exercises",+ "exerciseimage"+ ],+ [+ "add_muscle",+ "exercises",+ "muscle"+ ],+ [+ "change_muscle",+ "exercises",+ "muscle"+ ],+ [+ "delete_muscle",+ "exercises",+ "muscle"+ ]+ ]+ },+ "model": "auth.group",+ "pk": 6+ }]diff --git a/wger/core/management/commands/extract-i18n-flutter-exercises.py b/wger/core/management/commands/extract-i18n-flutter-exercises.pyindex d22cd0828..49ddc9ee3 100644--- a/wger/core/management/commands/extract-i18n-flutter-exercises.py+++ b/wger/core/management/commands/extract-i18n-flutter-exercises.py@@ -16,7 +16,7 @@from django.core.management.base import BaseCommand# wger-from wger.exercises.models import Exercise+from wger.exercises.models import Translationclass Command(BaseCommand):@@ -42,7 +42,7 @@ class Command(BaseCommand):self.stdout.write(f'Extracting translations for {exercise_key}')uuid = self.uuids[exercise_key]- translations = Exercise.objects.filter(exercise_base__uuid=uuid)+ translations = Translation.objects.filter(exercise_base__uuid=uuid)variables = []diff --git a/wger/exercises/api/serializers.py b/wger/exercises/api/serializers.pyindex a1148117b..fe858d638 100644--- a/wger/exercises/api/serializers.py+++ b/wger/exercises/api/serializers.py@@ -16,7 +16,6 @@from django.conf import settingsfrom django.core.cache import cachefrom django.db.models import Q-# Third Partyfrom rest_framework import serializers@@ -25,7 +24,7 @@ from wger.exercises.models import (Alias,DeletionLog,Equipment,- Exercise,+ Translation,ExerciseBase,ExerciseCategory,ExerciseComment,@@ -280,7 +279,7 @@ class ExerciseSerializer(serializers.ModelSerializer):author_history = serializers.ListSerializer(child=serializers.CharField())class Meta:- model = Exercise+ model = Translationfields = ('id','uuid',@@ -316,7 +315,7 @@ class ExerciseTranslationBaseInfoSerializer(serializers.ModelSerializer):author_history = serializers.ListSerializer(child=serializers.CharField())class Meta:- model = Exercise+ model = Translationfields = ('id','uuid',@@ -350,7 +349,7 @@ class ExerciseTranslationSerializer(serializers.ModelSerializer):)class Meta:- model = Exercise+ model = Translationfields = ('id','uuid',@@ -380,7 +379,7 @@ class ExerciseTranslationSerializer(serializers.ModelSerializer):# Creating a new object# -> Check if the language already existselse:- if Exercise.objects.filter(+ if Translation.objects.filter(exercise_base=value['exercise_base'],language=value['language'],).exists():@@ -408,7 +407,7 @@ class ExerciseInfoSerializer(serializers.ModelSerializer):author_history = serializers.ListSerializer(child=serializers.CharField())class Meta:- model = Exercise+ model = Translationdepth = 1fields = ['id',diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.pyindex b139429ab..abc701149 100644--- a/wger/exercises/api/views.py+++ b/wger/exercises/api/views.py@@ -17,6 +17,10 @@import loggingfrom uuid import UUID+# Third Party+import bleach+from actstream import action as actstream_action+from bleach.css_sanitizer import CSSSanitizer# Djangofrom django.conf import settingsfrom django.contrib.postgres.search import TrigramSimilarity@@ -24,11 +28,6 @@ from django.db.models import Qfrom django.utils.decorators import method_decoratorfrom django.utils.translation import gettext as _from django.views.decorators.cache import cache_page--# Third Party-import bleach-from actstream import action as actstream_action-from bleach.css_sanitizer import CSSSanitizerfrom drf_spectacular.types import OpenApiTypesfrom drf_spectacular.utils import (OpenApiParameter,@@ -72,7 +71,7 @@ from wger.exercises.models import (Alias,DeletionLog,Equipment,- Exercise,+ Translation,ExerciseBase,ExerciseCategory,ExerciseComment,@@ -92,7 +91,6 @@ from wger.utils.constants import (from wger.utils.db import is_postgres_dbfrom wger.utils.language import load_language-logger = logging.getLogger(__name__)@@ -153,7 +151,7 @@ class ExerciseTranslationViewSet(ModelViewSet):API endpoint for editing or adding exercise translation objects."""- queryset = Exercise.objects.all()+ queryset = Translation.objects.all()permission_classes = (CanContributeExercises,)serializer_class = ExerciseTranslationSerializerordering_fields = '__all__'@@ -223,7 +221,7 @@ class ExerciseViewSet(viewsets.ReadOnlyModelViewSet):This is only kept for backwards compatibility and will be removed in the future"""- queryset = Exercise.objects.all()+ queryset = Translation.objects.all()permission_classes = (CanContributeExercises,)serializer_class = ExerciseSerializerordering_fields = '__all__'@@ -251,7 +249,7 @@ class ExerciseViewSet(viewsets.ReadOnlyModelViewSet):def get_queryset(self):"""Add additional filters for fields from exercise base"""- qs = Exercise.objects.all()+ qs = Translation.objects.all()category = self.request.query_params.get('category')muscles = self.request.query_params.get('muscles')@@ -350,9 +348,9 @@ def search(request):# Filter the appropriate languageslanguages = [load_language(l) for l in language_codes.split(',')]if language_codes == SEARCH_ALL_LANGUAGES:- query = Exercise.objects.all()+ query = Translation.objects.all()else:- query = Exercise.objects.filter(language__in=languages)+ query = Translation.objects.filter(language__in=languages)query = query.only('name')@@ -400,7 +398,7 @@ class ExerciseInfoViewset(viewsets.ReadOnlyModelViewSet):API endpoint for exercise objects, use /api/v2/exercisebaseinfo/ instead."""- queryset = Exercise.objects.all()+ queryset = Translation.objects.all()serializer_class = ExerciseInfoSerializerordering_fields = '__all__'filterset_fields = (@@ -609,7 +607,7 @@ class ExerciseCommentViewSet(ModelViewSet):qs = ExerciseComment.objects.all()language = self.request.query_params.get('language')if language:- exercises = Exercise.objects.filter(language=language)+ exercises = Translation.objects.filter(language=language)qs = ExerciseComment.objects.filter(exercise__in=exercises)return qsdiff --git a/wger/exercises/apps.py b/wger/exercises/apps.pyindex 72a99b71d..d5606ac91 100644--- a/wger/exercises/apps.py+++ b/wger/exercises/apps.py@@ -23,12 +23,10 @@ class ExerciseConfig(AppConfig):verbose_name = 'Exercise'def ready(self):- import wger.exercises.signals-from actstream import registryregistry.register(self.get_model('Alias'))- registry.register(self.get_model('Exercise'))+ registry.register(self.get_model('Translation'))registry.register(self.get_model('ExerciseBase'))registry.register(self.get_model('ExerciseComment'))registry.register(self.get_model('ExerciseImage'))diff --git a/wger/exercises/fixtures/test-exercises.json b/wger/exercises/fixtures/test-exercises.jsonindex 179cfd154..6ff4dd561 100644--- a/wger/exercises/fixtures/test-exercises.json+++ b/wger/exercises/fixtures/test-exercises.json@@ -138,7 +138,7 @@},{"pk": 1,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "9838235c-e38f-4ca6-921e-9d237d8e0813","language": 2,@@ -151,7 +151,7 @@},{"pk": 2,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "7524ca8d-032e-482d-ab18-40e8a97851f6","language": 2,@@ -164,7 +164,7 @@},{"pk": 3,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "946afe7b-54a6-44a6-9c36-c3e31e6b4c3b","language": 2,@@ -177,7 +177,7 @@},{"pk": 4,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "5e80d257-3ece-43a1-b01d-2b28c6c288be","language": 2,@@ -191,7 +191,7 @@},{"pk": 5,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "13b532f9-d208-462e-a000-7b9982b2b53e","language": 3,@@ -205,7 +205,7 @@},{"pk": 6,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "e75335be-5177-4475-b17b-8d833c2aadf1","language": 3,@@ -219,7 +219,7 @@},{"pk": 7,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "3362115b-5743-4896-9bdd-4abc17b8cc86","language": 1,@@ -232,7 +232,7 @@},{"pk": 8,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "e75c421a-6839-4c14-b89a-bd2023818089","language": 2,@@ -245,7 +245,7 @@},{"pk": 9,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "c6286b86-026e-4fdb-9223-c8b011073678","language": 2,@@ -258,7 +258,7 @@},{"pk": 10,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "a2c9fac1-6d2c-4564-9300-0719d12a7ed1","language": 2,@@ -271,7 +271,7 @@},{"pk": 11,- "model": "exercises.exercise",+ "model": "exercises.translation","fields": {"uuid": "b589657e-5a8d-468a-9dc2-4d5b2237b394","language": 2,diff --git a/wger/exercises/management/commands/change-exercise-author.py b/wger/exercises/management/commands/change-exercise-author.pyindex 029270eec..4a7607b9c 100644--- a/wger/exercises/management/commands/change-exercise-author.py+++ b/wger/exercises/management/commands/change-exercise-author.py@@ -17,7 +17,7 @@ from django.core.management.base import BaseCommand# wgerfrom wger.exercises.models import ExerciseBase-from wger.exercises.models.exercise import Exercise+from wger.exercises.models import Translationclass Command(BaseCommand):@@ -70,7 +70,7 @@ class Command(BaseCommand):if exercise_id is not None:try:- exercise = Exercise.objects.get(id=exercise_id)+ exercise = Translation.objects.get(id=exercise_id)except ExerciseBase.DoesNotExist:self.print_error('Failed to find exercise')returndiff --git a/wger/exercises/management/commands/exercise-cleanup.py b/wger/exercises/management/commands/exercise-cleanup.pyindex c34d125c0..634b3c652 100755--- a/wger/exercises/management/commands/exercise-cleanup.py+++ b/wger/exercises/management/commands/exercise-cleanup.py@@ -21,7 +21,7 @@ from django.core.management.base import BaseCommand# wgerfrom wger.core.models import Languagefrom wger.exercises.models import (- Exercise,+ Translation,ExerciseBase,)@@ -59,7 +59,7 @@ class Command(BaseCommand):'author': '',}- exercise = Exercise.objects.filter(exercise_base=base, language=language).first()+ exercise = Translation.objects.filter(exercise_base=base, language=language).first()if exercise:exercise_data['uuid'] = exercise.uuidexercise_data['name'] = exercise.namediff --git a/wger/exercises/management/commands/read-exercise-cleanup.py b/wger/exercises/management/commands/read-exercise-cleanup.pyindex 768a30b8d..09afecd1a 100644--- a/wger/exercises/management/commands/read-exercise-cleanup.py+++ b/wger/exercises/management/commands/read-exercise-cleanup.py@@ -29,7 +29,7 @@ from wger.core.models import (from wger.exercises.models import (Alias,Equipment,- Exercise,+ Translation,ExerciseBase,ExerciseCategory,ExerciseVideo,@@ -37,7 +37,6 @@ from wger.exercises.models import ()from wger.utils.constants import CC_BY_SA_4_ID-UUID_NEW = 'NEW'VIDEO_AUTHOR = 'Goulart'VIDEO_PATH = pathlib.Path('videos-tmp')@@ -204,11 +203,11 @@ class Command(BaseCommand):continuetranslation = (- Exercise.objects.get_or_create(+ Translation.objects.get_or_create(uuid=exercise_uuid, defaults={'exercise_base': base, 'language': language})[0]if not new_translation- else Exercise()+ else Translation())translation.exercise_base = basetranslation.language = language@@ -281,15 +280,15 @@ class Command(BaseCommand):if translation_uuid:try:- Exercise.objects.filter(uuid=translation_uuid).delete()+ Translation.objects.filter(uuid=translation_uuid).delete()self.stdout.write(f'* Deleted translation {translation_uuid}')- except Exercise.DoesNotExist:+ except Translation.DoesNotExist:passif variation_id:try:Variation.objects.filter(id=variation_id).delete()self.stdout.write(f'* Deleted variation {variation_id}')- except Exercise.DoesNotExist:+ except Translation.DoesNotExist:passcsv_file.close()diff --git a/wger/exercises/management/commands/submitted-exercises.py b/wger/exercises/management/commands/submitted-exercises.pyindex 1f921d545..c932380b2 100644--- a/wger/exercises/management/commands/submitted-exercises.py+++ b/wger/exercises/management/commands/submitted-exercises.py@@ -16,7 +16,7 @@from django.core.management.base import BaseCommand# wger-from wger.exercises.models import Exercise+from wger.exercises.models import Translationclass Command(BaseCommand):@@ -29,7 +29,7 @@ class Command(BaseCommand):help = 'Read out the user submitted exercise'def handle(self, **options):- exercises = Exercise.objects.all()+ exercises = Translation.objects.all()usernames = []for exercise in exercises:if exercise.user not in usernames:diff --git a/wger/exercises/migrations/0032_rename_exercise.py b/wger/exercises/migrations/0032_rename_exercise.pynew file mode 100644index 000000000..32d37b972--- /dev/null+++ b/wger/exercises/migrations/0032_rename_exercise.py@@ -0,0 +1,20 @@+# Generated by Django 4.2.13 on 2024-06-12 12:59++from django.db import migrations+++class Migration(migrations.Migration):+ dependencies = [+ ('exercises', '0030_increase_author_field_length'),+ ]++ operations = [+ migrations.RenameModel(+ old_name='Exercise',+ new_name='Translation',+ ),+ migrations.RenameModel(+ old_name='HistoricalExercise',+ new_name='HistoricalTranslation',+ ),+ ]diff --git a/wger/exercises/models/__init__.py b/wger/exercises/models/__init__.pyindex ddb7e1366..444906b7e 100644--- a/wger/exercises/models/__init__.py+++ b/wger/exercises/models/__init__.py@@ -20,9 +20,9 @@ from .category import ExerciseCategoryfrom .comment import ExerciseCommentfrom .deletion_log import DeletionLogfrom .equipment import Equipment-from .exercise import Exercisefrom .exercise_alias import Aliasfrom .image import ExerciseImagefrom .muscle import Muscle+from .translation import Translationfrom .variation import Variationfrom .video import ExerciseVideodiff --git a/wger/exercises/models/base.py b/wger/exercises/models/base.pyindex fbd02ba7b..3ccb93d88 100644--- a/wger/exercises/models/base.py+++ b/wger/exercises/models/base.py@@ -24,14 +24,13 @@ from typing import (# Djangofrom django.core.checks import Warning-from django.db import models+from django.db import models, OperationalErrorfrom django.db.models import Qfrom django.urls import reversefrom django.utils.translation import (get_language,gettext_lazy as _,)-# Third Partyfrom simple_history.models import HistoricalRecords@@ -49,7 +48,6 @@ from wger.utils.models import (AbstractLicenseModel,collect_models_author_history,)-# Localfrom .category import ExerciseCategoryfrom .equipment import Equipment@@ -145,17 +143,22 @@ class ExerciseBase(AbstractLicenseModel, AbstractHistoryMixin, models.Model):def check(cls, **kwargs):errors = super().check(**kwargs)- no_translations = cls.no_translations.all().count()- if no_translations:- errors.append(- Warning(- 'exercises without translations',- hint=f'There are {no_translations} exercises without translations, this will '- 'cause problems! You can output or delete them with "python manage.py '- 'exercises-health-check --help"',- id='wger.W002',+ try:+ no_translations = cls.no_translations.all().count()+ if no_translations:+ errors.append(+ Warning(+ 'exercises without translations',+ hint=f'There are {no_translations} exercises without translations, this will '+ 'cause problems! You can output or delete them with "python manage.py '+ 'exercises-health-check --help"',+ id='wger.W002',+ ))- )+ except OperationalError:+ # This check runs before the migrations that rename the table "exercise"+ # to "translations" so if there are any errors, just ignore them+ passreturn errors@@ -222,18 +225,18 @@ class ExerciseBase(AbstractLicenseModel, AbstractHistoryMixin, models.Model):have deleted the English translation or similar"""# wger- from wger.exercises.models import Exercise+ from wger.exercises.models import Translationlanguage = language or get_language()try:translation = self.exercises.get(language__short_name=language)- except Exercise.DoesNotExist:+ except Translation.DoesNotExist:try:translation = self.exercises.get(language__short_name=ENGLISH_SHORT_NAME)- except Exercise.DoesNotExist:+ except Translation.DoesNotExist:translation = self.exercises.first()- except Exercise.MultipleObjectsReturned:+ except Translation.MultipleObjectsReturned:translation = self.exercises.filter(language__short_name=language).first()return translationdiff --git a/wger/exercises/models/comment.py b/wger/exercises/models/comment.pyindex ce22ecf6e..cf619559e 100644--- a/wger/exercises/models/comment.py+++ b/wger/exercises/models/comment.py@@ -20,15 +20,13 @@ import uuid# Djangofrom django.db import modelsfrom django.utils.translation import gettext_lazy as _-# Third Partyfrom simple_history.models import HistoricalRecords# wgerfrom wger.utils.cache import reset_exercise_api_cache-# Local-from .exercise import Exercise+from .translation import Translationclass ExerciseComment(models.Model):@@ -45,7 +43,7 @@ class ExerciseComment(models.Model):"""Globally unique ID, to identify the comment across installations"""exercise = models.ForeignKey(- Exercise,+ Translation,verbose_name=_('Exercise'),on_delete=models.CASCADE,)diff --git a/wger/exercises/models/exercise_alias.py b/wger/exercises/models/exercise_alias.pyindex 8a3a51ce1..bc9d505bc 100644--- a/wger/exercises/models/exercise_alias.py+++ b/wger/exercises/models/exercise_alias.py@@ -21,15 +21,13 @@ import uuidfrom django.contrib.postgres.indexes import GinIndexfrom django.db import modelsfrom django.utils.translation import gettext_lazy as _-# Third Partyfrom simple_history.models import HistoricalRecords# wgerfrom wger.utils.cache import reset_exercise_api_cache-# Local-from .exercise import Exercise+from .translation import Translationclass Alias(models.Model):@@ -46,7 +44,7 @@ class Alias(models.Model):"""Globally unique ID, to identify the alias across installations"""exercise = models.ForeignKey(- Exercise,+ Translation,verbose_name=_('Exercise'),on_delete=models.CASCADE,)diff --git a/wger/exercises/models/exercise.py b/wger/exercises/models/translation.pysimilarity index 97%rename from wger/exercises/models/exercise.pyrename to wger/exercises/models/translation.pyindex 28b547cf9..9c30e9a4c 100644--- a/wger/exercises/models/exercise.py+++ b/wger/exercises/models/translation.py@@ -17,6 +17,8 @@# Standard Libraryimport uuid+# Third Party+import bleach# Djangofrom django.contrib.postgres.indexes import GinIndexfrom django.core.validators import MinLengthValidator@@ -24,9 +26,6 @@ from django.db import modelsfrom django.urls import reversefrom django.utils.text import slugifyfrom django.utils.translation import gettext_lazy as _--# Third Party-import bleachfrom simple_history.models import HistoricalRecords# wger@@ -39,9 +38,9 @@ from wger.utils.models import ()-class Exercise(AbstractLicenseModel, AbstractHistoryMixin, models.Model):+class Translation(AbstractLicenseModel, AbstractHistoryMixin, models.Model):"""- Model for an exercise+ Model for an exercise translation"""description = models.TextField(diff --git a/wger/exercises/signals.py b/wger/exercises/signals.pyindex 1a350333a..a925865b6 100644--- a/wger/exercises/signals.py+++ b/wger/exercises/signals.py@@ -24,7 +24,6 @@ from django.db.models.signals import (pre_save,)from django.dispatch import receiver-# Third Partyfrom easy_thumbnails.files import get_thumbnailerfrom easy_thumbnails.signal_handlers import generate_aliases@@ -33,7 +32,7 @@ from easy_thumbnails.signals import saved_file# wgerfrom wger.exercises.models import (DeletionLog,- Exercise,+ Translation,ExerciseImage,ExerciseVideo,)@@ -112,8 +111,8 @@ def delete_exercise_video_on_update(sender, instance: ExerciseVideo, **kwargs):# pass-@receiver(pre_delete, sender=Exercise)-def add_deletion_log_translation(sender, instance: Exercise, **kwargs):+@receiver(pre_delete, sender=Translation)+def add_deletion_log_translation(sender, instance: Translation, **kwargs):log = DeletionLog(model_type=DeletionLog.MODEL_TRANSLATION,uuid=instance.uuid,diff --git a/wger/exercises/sitemap.py b/wger/exercises/sitemap.pyindex 032cc735f..2e2444449 100644--- a/wger/exercises/sitemap.py+++ b/wger/exercises/sitemap.py@@ -18,7 +18,7 @@from django.contrib.sitemaps import Sitemap# wger-from wger.exercises.models import Exercise+from wger.exercises.models import Translationclass ExercisesSitemap(Sitemap):@@ -26,7 +26,7 @@ class ExercisesSitemap(Sitemap):priority = 0.5def items(self):- return Exercise.objects.all()+ return Translation.objects.all()def lastmod(self, obj):return obj.last_updatediff --git a/wger/exercises/sync.py b/wger/exercises/sync.pyindex 63dd74f54..a2afd3b53 100644--- a/wger/exercises/sync.py+++ b/wger/exercises/sync.py@@ -15,14 +15,13 @@# Standard Libraryimport os+# Third Party+import requests# Djangofrom django.conf import settingsfrom django.core.files import Filefrom django.core.files.temp import NamedTemporaryFile-# Third Party-import requests-# wgerfrom wger.core.api.endpoints import (LANGUAGE_ENDPOINT,@@ -45,7 +44,7 @@ from wger.exercises.models import (Alias,DeletionLog,Equipment,- Exercise,+ Translation,ExerciseBase,ExerciseCategory,ExerciseComment,@@ -101,7 +100,7 @@ def sync_exercises(description = translation_data['description']language_id = translation_data['language']- translation, translation_created = Exercise.objects.update_or_create(+ translation, translation_created = Translation.objects.update_or_create(uuid=trans_uuid,defaults={'exercise_base': base,@@ -296,7 +295,6 @@ def handle_deleted_entries(style_fn=lambda x: x,):if not print_fn:-def print_fn(_):return None@@ -344,10 +342,10 @@ def handle_deleted_entries(elif model_type == DeletionLog.MODEL_TRANSLATION:try:- obj = Exercise.objects.get(uuid=uuid)+ obj = Translation.objects.get(uuid=uuid)obj.delete()print_fn(f"Deleted translation {uuid} ({data['comment']})")- except Exercise.DoesNotExist:+ except Translation.DoesNotExist:passelif model_type == DeletionLog.MODEL_IMAGE:diff --git a/wger/exercises/tests/test_change_exercise_author.py b/wger/exercises/tests/test_change_exercise_author.pyindex c154a5899..c7c848cee 100644--- a/wger/exercises/tests/test_change_exercise_author.py+++ b/wger/exercises/tests/test_change_exercise_author.py@@ -20,8 +20,8 @@ from django.core.management import call_command# wgerfrom wger.core.tests.base_testcase import WgerTestCase+from wger.exercises.models import Translationfrom wger.exercises.models.base import ExerciseBase-from wger.exercises.models.exercise import Exerciseclass ChangeExerciseAuthorTestCase(WgerTestCase):@@ -66,12 +66,12 @@ class ChangeExerciseAuthorTestCase(WgerTestCase):"""Test to ensure command can handle an exercise id passed"""- exercise = Exercise.objects.get(id=1)+ exercise = Translation.objects.get(id=1)self.assertNotEqual(exercise.license_author, 'tom')args = ['--author-name', 'tom', '--exercise-id', '1']call_command('change-exercise-author', *args, stdout=self.out, no_color=True)self.assertIn('Exercise and/or exercise base has been updated', self.out.getvalue())- exercise = Exercise.objects.get(id=1)+ exercise = Translation.objects.get(id=1)self.assertEqual(exercise.license_author, 'tom')diff --git a/wger/exercises/tests/test_deletion_log.py b/wger/exercises/tests/test_deletion_log.pyindex a0db87fce..6464fa721 100644--- a/wger/exercises/tests/test_deletion_log.py+++ b/wger/exercises/tests/test_deletion_log.py@@ -19,7 +19,7 @@ from uuid import UUIDfrom wger.core.tests.base_testcase import WgerTestCasefrom wger.exercises.models import (DeletionLog,- Exercise,+ Translation,ExerciseBase,)@@ -108,7 +108,7 @@ class DeletionLogTestCase(WgerTestCase):"""self.assertEqual(DeletionLog.objects.all().count(), 0)- translation = Exercise.objects.get(pk=1)+ translation = Translation.objects.get(pk=1)translation.delete()# Translation is deleteddiff --git a/wger/exercises/tests/test_exercise_api_cache.py b/wger/exercises/tests/test_exercise_api_cache.pyindex 07fdeb927..3ddbb848e 100644--- a/wger/exercises/tests/test_exercise_api_cache.py+++ b/wger/exercises/tests/test_exercise_api_cache.py@@ -19,7 +19,7 @@ from django.core.cache import cachefrom wger.core.tests.base_testcase import WgerTestCasefrom wger.exercises.models import (Alias,- Exercise,+ Translation,ExerciseBase,ExerciseComment,)@@ -72,7 +72,7 @@ class ExerciseApiCacheTestCase(WgerTestCase):self.client.get(self.url)self.assertTrue(cache.get(self.cache_key))- translation = Exercise.objects.get(pk=1)+ translation = Translation.objects.get(pk=1)translation.name = 'something else'translation.save()@@ -86,7 +86,7 @@ class ExerciseApiCacheTestCase(WgerTestCase):self.client.get(self.url)self.assertTrue(cache.get(self.cache_key))- translation = Exercise.objects.get(pk=1)+ translation = Translation.objects.get(pk=1)translation.delete()self.assertFalse(cache.get(self.cache_key))diff --git a/wger/exercises/tests/test_exercise_base.py b/wger/exercises/tests/test_exercise_base.pyindex 0fd6d9e5b..7b9711af2 100644--- a/wger/exercises/tests/test_exercise_base.py+++ b/wger/exercises/tests/test_exercise_base.py@@ -23,7 +23,7 @@ from wger.core.tests.api_base_test import ExerciseCrudApiTestCasefrom wger.core.tests.base_testcase import WgerTestCasefrom wger.exercises.models import (DeletionLog,- Exercise,+ Translation,ExerciseBase,)from wger.utils.constants import CC_BY_SA_4_ID@@ -43,7 +43,7 @@ class ExerciseBaseTestCase(WgerTestCase):"""Test that the properties return the correct data"""- translation = Exercise.objects.get(pk=1)+ translation = Translation.objects.get(pk=1)exercise = translation.exercise_baseself.assertEqual(exercise.category, translation.category)self.assertListEqual(self.get_ids(exercise.equipment), self.get_ids(translation.equipment))@@ -90,7 +90,7 @@ class ExerciseBaseTestCase(WgerTestCase):def test_images(self):"""Test that the correct images are returned for the exercises"""- translation = Exercise.objects.get(pk=1)+ translation = Translation.objects.get(pk=1)exercise = translation.exercise_baseself.assertListEqual(self.get_ids(translation.images), self.get_ids(exercise.exerciseimage_set)diff --git a/wger/exercises/tests/test_exercise_base_model.py b/wger/exercises/tests/test_exercise_base_model.pyindex 76c363a4f..52ad35884 100644--- a/wger/exercises/tests/test_exercise_base_model.py+++ b/wger/exercises/tests/test_exercise_base_model.py@@ -18,7 +18,7 @@ import datetime# wgerfrom wger.core.tests.base_testcase import WgerTestCasefrom wger.exercises.models import (- Exercise,+ Translation,ExerciseBase,)@@ -30,8 +30,8 @@ class ExerciseBaseTranslationHandlingTestCase(WgerTestCase):def setUp(self):super().setUp()- Exercise.objects.get(pk=1).delete()- Exercise.objects.get(pk=5).delete()+ Translation.objects.get(pk=1).delete()+ Translation.objects.get(pk=5).delete()def test_managers(self):self.assertEqual(ExerciseBase.translations.all().count(), 7)diff --git a/wger/exercises/tests/test_exercise_images.py b/wger/exercises/tests/test_exercise_images.pyindex 728a2f3a5..42997fc29 100644--- a/wger/exercises/tests/test_exercise_images.py+++ b/wger/exercises/tests/test_exercise_images.py@@ -14,18 +14,14 @@# Djangofrom django.core.files import File-from django.urls import reverse# wgerfrom wger.core.tests import api_base_testfrom wger.core.tests.base_testcase import (- WgerAddTestCase,- WgerDeleteTestCase,- WgerEditTestCase,WgerTestCase,)from wger.exercises.models import (- Exercise,+ Translation,ExerciseImage,)@@ -53,7 +49,7 @@ class MainImageTestCase(WgerTestCase):Tests that the first uploaded image is automatically a main image"""- exercise = Exercise.objects.get(pk=2)+ exercise = Translation.objects.get(pk=2)pk = self.save_image(exercise, 'protestschwein.jpg')image = ExerciseImage.objects.get(pk=pk)@@ -64,7 +60,7 @@ class MainImageTestCase(WgerTestCase):Tests that there is always a main image after deleting one"""- exercise = Exercise.objects.get(pk=2)+ exercise = Translation.objects.get(pk=2)pk1 = self.save_image(exercise, 'protestschwein.jpg')pk2 = self.save_image(exercise, 'wildschwein.jpg')@@ -79,7 +75,7 @@ class MainImageTestCase(WgerTestCase):Tests that there is always a main image after deleting one"""- exercise = Exercise.objects.get(pk=2)+ exercise = Translation.objects.get(pk=2)pk1 = self.save_image(exercise, 'protestschwein.jpg')pk2 = self.save_image(exercise, 'protestschwein.jpg')pk3 = self.save_image(exercise, 'wildschwein.jpg')diff --git a/wger/exercises/tests/test_exercise_model.py b/wger/exercises/tests/test_exercise_model.pyindex 947027633..11da16f6c 100644--- a/wger/exercises/tests/test_exercise_model.py+++ b/wger/exercises/tests/test_exercise_model.py@@ -14,7 +14,7 @@# wgerfrom wger.core.tests.base_testcase import WgerTestCase-from wger.exercises.models import Exercise+from wger.exercises.models import Translationclass ExerciseModelTestCase(WgerTestCase):@@ -24,15 +24,15 @@ class ExerciseModelTestCase(WgerTestCase):def test_absolute_url_name(self):"""Test that the get_absolute_url returns the correct URL"""- exercise = Exercise(exercise_base_id=1, description='abc', name='foo')+ exercise = Translation(exercise_base_id=1, description='abc', name='foo')self.assertEqual(exercise.get_absolute_url(), '/en/exercise/1/view-base/foo')def test_absolute_url_no_name(self):"""Test that the get_absolute_url returns the correct URL"""- exercise = Exercise(exercise_base_id=2, description='abc', name='')+ exercise = Translation(exercise_base_id=2, description='abc', name='')self.assertEqual(exercise.get_absolute_url(), '/en/exercise/2/view-base')def test_absolute_url_no_name2(self):"""Test that the get_absolute_url returns the correct URL"""- exercise = Exercise(exercise_base_id=42, description='abc', name='@@@@@')+ exercise = Translation(exercise_base_id=42, description='abc', name='@@@@@')self.assertEqual(exercise.get_absolute_url(), '/en/exercise/42/view-base')diff --git a/wger/exercises/tests/test_exercise_translation.py b/wger/exercises/tests/test_exercise_translation.pyindex ace1b10ea..1f06a6d2b 100644--- a/wger/exercises/tests/test_exercise_translation.py+++ b/wger/exercises/tests/test_exercise_translation.py@@ -16,13 +16,11 @@import json# Django-from django.core.cache import cachefrom django.template import (Context,Template,)from django.urls import reverse-# Third Partyfrom rest_framework import status@@ -30,14 +28,12 @@ from rest_framework import statusfrom wger.core.tests import api_base_testfrom wger.core.tests.api_base_test import ExerciseCrudApiTestCasefrom wger.core.tests.base_testcase import (- WgerDeleteTestCase,WgerTestCase,)from wger.exercises.models import (- Exercise,+ Translation,Muscle,)-from wger.utils.cache import cache_mapperfrom wger.utils.constants import CC_BY_SA_4_ID@@ -50,7 +46,7 @@ class ExerciseRepresentationTestCase(WgerTestCase):"""Test that the representation of an object is correct"""- self.assertEqual(str(Exercise.objects.get(pk=1)), 'An exercise')+ self.assertEqual(str(Translation.objects.get(pk=1)), 'An exercise')class ExercisesTestCase(WgerTestCase):@@ -99,7 +95,7 @@ class ExercisesTestCase(WgerTestCase):"""Test that changing exercise details generates a historical record"""- exercise = Exercise.objects.get(pk=2)+ exercise = Translation.objects.get(pk=2)self.assertEqual(len(exercise.history.all()), 0)exercise.name = 'Very cool exercise 2'@@ -107,7 +103,7 @@ class ExercisesTestCase(WgerTestCase):exercise.exercise_base.muscles_secondary.add(Muscle.objects.get(pk=2))exercise.save()- exercise = Exercise.objects.get(pk=2)+ exercise = Translation.objects.get(pk=2)self.assertEqual(len(exercise.history.all()), 1)@@ -225,10 +221,13 @@ class ExerciseApiTestCase("""pk = 1- resource = Exercise+ resource = Translationprivate_resource = Falseoverview_cached = True+ def get_resource_name(self):+ return 'exercise'+class ExerciseInfoApiTestCase(api_base_test.BaseTestCase,@@ -282,45 +281,45 @@ class ExerciseCustomApiTestCase(ExerciseCrudApiTestCase):Test that it is not possible to change the base id of an existingexercise translation."""- exercise = Exercise.objects.get(pk=self.pk)- self.assertEqual(exercise.exercise_base_id, 1)+ translation = Translation.objects.get(pk=self.pk)+ self.assertEqual(translation.exercise_base_id, 1)self.authenticate('trainer1')response = self.client.patch(self.url_detail, data={'exercise_base': 2})self.assertEqual(response.status_code, status.HTTP_200_OK)- exercise = Exercise.objects.get(pk=self.pk)- self.assertEqual(exercise.exercise_base_id, 1)+ translation = Translation.objects.get(pk=self.pk)+ self.assertEqual(translation.exercise_base_id, 1)def test_cant_change_language(self):"""Test that it is not possible to change the language id of an existingexercise translation."""- exercise = Exercise.objects.get(pk=self.pk)- self.assertEqual(exercise.language_id, 2)+ translation = Translation.objects.get(pk=self.pk)+ self.assertEqual(translation.language_id, 2)self.authenticate('trainer1')response = self.client.patch(self.url_detail, data={'language': 1})self.assertEqual(response.status_code, status.HTTP_200_OK)- exercise = Exercise.objects.get(pk=self.pk)- self.assertEqual(exercise.language_id, 2)+ translation = Translation.objects.get(pk=self.pk)+ self.assertEqual(translation.language_id, 2)def test_cant_change_license(self):"""Test that it is not possible to change the license of an existingexercise translation."""- exercise = Exercise.objects.get(pk=self.pk)- self.assertEqual(exercise.license_id, 2)+ translation = Translation.objects.get(pk=self.pk)+ self.assertEqual(translation.license_id, 2)self.authenticate('trainer1')response = self.client.patch(self.url_detail, data={'license': 3})self.assertEqual(response.status_code, status.HTTP_200_OK)- exercise = Exercise.objects.get(pk=self.pk)- self.assertEqual(exercise.license_id, 2)+ translation = Translation.objects.get(pk=self.pk)+ self.assertEqual(translation.license_id, 2)def test_cant_set_license(self):"""@@ -333,8 +332,8 @@ class ExerciseCustomApiTestCase(ExerciseCrudApiTestCase):response = self.client.post(self.url, data=self.data)self.assertEqual(response.status_code, status.HTTP_201_CREATED)- exercise = Exercise.objects.get(pk=self.pk)- self.assertEqual(exercise.license_id, CC_BY_SA_4_ID)+ translation = Translation.objects.get(pk=self.pk)+ self.assertEqual(translation.license_id, CC_BY_SA_4_ID)def test_patch_clean_html(self):"""@@ -345,8 +344,8 @@ class ExerciseCustomApiTestCase(ExerciseCrudApiTestCase):response = self.client.patch(self.url_detail, data={'description': description})self.assertEqual(response.status_code, status.HTTP_200_OK)- exercise = Exercise.objects.get(pk=self.pk)- self.assertEqual(exercise.description, 'alert(); The wild boar is a suid native...')+ translation = Translation.objects.get(pk=self.pk)+ self.assertEqual(translation.description, 'alert(); The wild boar is a suid native...')def test_post_only_one_language_per_base(self):"""diff --git a/wger/exercises/tests/test_history.py b/wger/exercises/tests/test_history.pyindex 9d93f5116..4e826bcfd 100644--- a/wger/exercises/tests/test_history.py+++ b/wger/exercises/tests/test_history.py@@ -11,20 +11,17 @@# GNU General Public License for more details.## You should have received a copy of the GNU Affero General Public License-# Standard Library-from time import sleep+# Third Party+from actstream import action as actstream_action# Djangofrom django.contrib.auth.models import Userfrom django.contrib.contenttypes.models import ContentTypefrom django.urls import reverse-# Third Party-from actstream import action as actstream_action-# wgerfrom wger.core.tests.base_testcase import WgerTestCase-from wger.exercises.models import Exercise+from wger.exercises.models import Translationfrom wger.exercises.views.helper import StreamVerbs@@ -39,17 +36,17 @@ class ExerciseHistoryControl(WgerTestCase):"""self.user_login()- exercise = Exercise.objects.get(pk=2)+ translation = Translation.objects.get(pk=2)- exercise.save()- exercise.name = 'Very cool exercise!'- exercise.save()+ translation.save()+ translation.name = 'Very cool exercise!'+ translation.save()- exercise = Exercise.objects.get(pk=2)+ translation = Translation.objects.get(pk=2)actstream_action.send(User.objects.all().first(),verb=StreamVerbs.UPDATED.value,- action_object=exercise,+ action_object=translation,)response = self.client.get(reverse('exercise:history:overview'))@@ -63,23 +60,23 @@ class ExerciseHistoryControl(WgerTestCase):"""self.user_login()- exercise = Exercise.objects.get(pk=2)- exercise.description = 'Boring exercise'- exercise.save()+ translation = Translation.objects.get(pk=2)+ translation.description = 'Boring exercise'+ translation.save()- most_recent_history = exercise.history.order_by('history_date').last()- exercise.description = 'Very cool exercise!'- exercise.save()+ most_recent_history = translation.history.order_by('history_date').last()+ translation.description = 'Very cool exercise!'+ translation.save()self.client.get(reverse('exercise:history:revert',kwargs={'history_pk': most_recent_history.history_id,- 'content_type_id': ContentType.objects.get_for_model(exercise).id,+ 'content_type_id': ContentType.objects.get_for_model(translation).id,},))- exercise = Exercise.objects.get(pk=2)- self.assertEqual(exercise.description, 'Boring exercise')+ translation = Translation.objects.get(pk=2)+ self.assertEqual(translation.description, 'Boring exercise')diff --git a/wger/exercises/tests/test_management_commands.py b/wger/exercises/tests/test_management_commands.pyindex 8d0a5a206..eae66e6ba 100644--- a/wger/exercises/tests/test_management_commands.py+++ b/wger/exercises/tests/test_management_commands.py@@ -22,7 +22,7 @@ from django.test import SimpleTestCase# wgerfrom wger.core.tests.base_testcase import WgerTestCasefrom wger.exercises.models import (- Exercise,+ Translation,ExerciseBase,)@@ -78,8 +78,8 @@ class TestHealthCheckManagementCommands(WgerTestCase):self.assertEqual('', self.out.getvalue())def test_find_untranslated(self):- Exercise.objects.get(pk=1).delete()- Exercise.objects.get(pk=5).delete()+ Translation.objects.get(pk=1).delete()+ Translation.objects.get(pk=5).delete()call_command('exercises-health-check', stdout=self.out)self.assertIn(@@ -89,14 +89,14 @@ class TestHealthCheckManagementCommands(WgerTestCase):self.assertNotIn('-> deleted', self.out.getvalue())def atest_fix_untranslated(self):- Exercise.objects.get(pk=1).delete()+ Translation.objects.get(pk=1).delete()call_command('exercises-health-check', '--delete-untranslated', stdout=self.out)self.assertIn('-> deleted', self.out.getvalue())self.assertRaises(ExerciseBase.DoesNotExist, ExerciseBase.objects.get, pk=1)def test_find_no_english_translation(self):- Exercise.objects.get(pk=1).delete()+ Translation.objects.get(pk=1).delete()call_command('exercises-health-check', stdout=self.out)self.assertIn(@@ -106,14 +106,14 @@ class TestHealthCheckManagementCommands(WgerTestCase):self.assertNotIn('-> deleted', self.out.getvalue())def test_fix_no_english_translation(self):- Exercise.objects.get(pk=1).delete()+ Translation.objects.get(pk=1).delete()call_command('exercises-health-check', '--delete-no-english', stdout=self.out)self.assertIn('-> deleted', self.out.getvalue())self.assertRaises(ExerciseBase.DoesNotExist, ExerciseBase.objects.get, pk=1)def test_find_duplicate_translations(self):- exercise = Exercise.objects.get(pk=1)+ exercise = Translation.objects.get(pk=1)exercise.language_id = 3exercise.save()@@ -125,10 +125,10 @@ class TestHealthCheckManagementCommands(WgerTestCase):self.assertNotIn('-> deleted', self.out.getvalue())def test_fix_duplicate_translations(self):- exercise = Exercise.objects.get(pk=1)+ exercise = Translation.objects.get(pk=1)exercise.language_id = 3exercise.save()call_command('exercises-health-check', '--delete-duplicate-translations', stdout=self.out)self.assertIn('Deleting all but first fr translation', self.out.getvalue())- self.assertRaises(Exercise.DoesNotExist, Exercise.objects.get, pk=5)+ self.assertRaises(Translation.DoesNotExist, Translation.objects.get, pk=5)diff --git a/wger/exercises/tests/test_sync.py b/wger/exercises/tests/test_sync.pyindex 92fc5e263..d7bff302c 100644--- a/wger/exercises/tests/test_sync.py+++ b/wger/exercises/tests/test_sync.py@@ -23,7 +23,7 @@ from wger.core.models import (from wger.core.tests.base_testcase import WgerTestCasefrom wger.exercises.models import (Equipment,- Exercise,+ Translation,ExerciseBase,ExerciseCategory,Muscle,@@ -648,7 +648,7 @@ class TestSyncMethods(WgerTestCase):@patch('requests.get', return_value=MockDeletionLogResponse())def test_deletion_log(self, mock_request):self.assertEqual(ExerciseBase.objects.count(), 8)- self.assertEqual(Exercise.objects.count(), 11)+ self.assertEqual(Translation.objects.count(), 11)exercise1 = ExerciseBase.objects.get(pk=1)exercise2 = ExerciseBase.objects.get(pk=4)@@ -665,8 +665,8 @@ class TestSyncMethods(WgerTestCase):headers=wger_headers(),)self.assertEqual(ExerciseBase.objects.count(), 7)- self.assertEqual(Exercise.objects.count(), 8)- self.assertRaises(Exercise.DoesNotExist, Exercise.objects.get, pk=3)+ self.assertEqual(Translation.objects.count(), 8)+ self.assertRaises(Translation.DoesNotExist, Translation.objects.get, pk=3)self.assertRaises(ExerciseBase.DoesNotExist, ExerciseBase.objects.get, pk=1)# Workouts and logs have been moved@@ -678,7 +678,7 @@ class TestSyncMethods(WgerTestCase):@patch('requests.get', return_value=MockExerciseResponse())def test_exercise_sync(self, mock_request):self.assertEqual(ExerciseBase.objects.count(), 8)- self.assertEqual(Exercise.objects.count(), 11)+ self.assertEqual(Translation.objects.count(), 11)exercise = ExerciseBase.objects.get(uuid='ae3328ba-9a35-4731-bc23-5da50720c5aa')self.assertEqual(exercise.category_id, 2)@@ -689,7 +689,7 @@ class TestSyncMethods(WgerTestCase):headers=wger_headers(),)self.assertEqual(ExerciseBase.objects.count(), 9)- self.assertEqual(Exercise.objects.count(), 14)+ self.assertEqual(Translation.objects.count(), 14)# New exercise was creatednew_exercise = ExerciseBase.objects.get(uuid='1b020b3a-3732-4c7e-92fd-a0cec90ed69b')diff --git a/wger/exercises/views/exercises.py b/wger/exercises/views/exercises.pyindex 52c4cceb5..46879ca6e 100644--- a/wger/exercises/views/exercises.py+++ b/wger/exercises/views/exercises.py@@ -33,14 +33,12 @@ from django.utils.translation import ()from django.views.generic import (DeleteView,- TemplateView,)# wger-from wger.exercises.models import Exercise+from wger.exercises.models import Translationfrom wger.utils.generic_views import WgerDeleteMixin-logger = logging.getLogger(__name__)@@ -48,7 +46,7 @@ def view(request, id, slug=None):"""Detail view for an exercise translation"""- exercise = get_object_or_404(Exercise, pk=id)+ exercise = get_object_or_404(Translation, pk=id)return HttpResponsePermanentRedirect(reverse(@@ -67,7 +65,7 @@ class ExerciseDeleteView(Generic view to delete an existing exercise"""- model = Exercise+ model = Translationsuccess_url = reverse_lazy('exercise:exercise:overview')delete_message_extra = gettext_lazy('This will delete the exercise from all workouts.')messages = gettext_lazy('Successfully deleted')