Self hosted FLOSS fitness/workout, nutrition and weight tracker
Remove the status field from the exercise model
Roland Geider206b44cb635b
diff --git a/wger/core/tests/api_base_test.py b/wger/core/tests/api_base_test.pyindex c4b792a67..fb2724d44 100644--- a/wger/core/tests/api_base_test.py+++ b/wger/core/tests/api_base_test.py@@ -200,17 +200,17 @@ class ApiPostTestCase(object):else:# Anonymous userresponse = self.client.post(self.url_detail, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Authorized user (owner)self.get_credentials()response = self.client.post(self.url_detail, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Different logged in userself.get_credentials(self.user_fail)response = self.client.post(self.url_detail, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))def test_post(self):"""@@ -239,17 +239,17 @@ class ApiPostTestCase(object):else:# Anonymous userresponse = self.client.post(self.url, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Logged in userself.get_credentials()response = self.client.post(self.url, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Different logged in userself.get_credentials(self.user_fail)response = self.client.post(self.url, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))def test_post_special_endpoints(self):"""@@ -310,17 +310,17 @@ class ApiPatchTestCase(object):else:# Anonymous userresponse = self.client.patch(self.url_detail, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Authorized user (owner)self.get_credentials()response = self.client.patch(self.url_detail, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Different logged in userself.get_credentials(self.user_fail)response = self.client.patch(self.url_detail, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))def test_patch(self):"""@@ -334,17 +334,17 @@ class ApiPatchTestCase(object):else:# Anonymous userresponse = self.client.patch(self.url, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Logged in userself.get_credentials()response = self.client.patch(self.url, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Different logged in userself.get_credentials(self.user_fail)response = self.client.patch(self.url, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))def test_patch_special_endpoints(self):"""@@ -417,17 +417,17 @@ class ApiPutTestCase(object):else:# Anonymous userresponse = self.client.put(self.url_detail, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Authorized user (owner)self.get_credentials()response = self.client.put(self.url_detail, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Different logged in userself.get_credentials(self.user_fail)response = self.client.put(self.url_detail, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))def test_put(self):"""@@ -442,17 +442,17 @@ class ApiPutTestCase(object):else:# Anonymous userresponse = self.client.put(self.url, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Authorized user (owner)self.get_credentials()response = self.client.put(self.url, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Different logged in userself.get_credentials(self.user_fail)response = self.client.put(self.url, data=self.data)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))def test_put_special_endpoints(self):"""@@ -511,17 +511,17 @@ class ApiDeleteTestCase(object):else:# Anonymous userresponse = self.client.delete(self.url_detail)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Logged in userself.get_credentials()response = self.client.delete(self.url_detail)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Different logged in userself.get_credentials(self.user_fail)response = self.client.delete(self.url_detail)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))def test_delete(self):"""@@ -544,17 +544,17 @@ class ApiDeleteTestCase(object):else:# Anonymous userresponse = self.client.delete(self.url)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Authorized user (owner)self.get_credentials()response = self.client.delete(self.url)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))# Different logged in userself.get_credentials(self.user_fail)response = self.client.delete(self.url)- self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)+ self.assertIn(response.status_code, (status.HTTP_405_METHOD_NOT_ALLOWED, status.HTTP_403_FORBIDDEN))def test_delete_special_endpoints(self):"""diff --git a/wger/exercises/api/serializers.py b/wger/exercises/api/serializers.pyindex c68490b80..3281c18ec 100644--- a/wger/exercises/api/serializers.py+++ b/wger/exercises/api/serializers.py@@ -200,7 +200,6 @@ class ExerciseSerializer(serializers.ModelSerializer):"uuid","name","exercise_base",- "status","description","creation_date","category",diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.pyindex 921e2be83..8c6b112c8 100644--- a/wger/exercises/api/views.py+++ b/wger/exercises/api/views.py@@ -76,7 +76,7 @@ class ExerciseBaseViewSet(CreateUpdateModelViewSet):API endpoint for exercise base objects. For a read-only endpoint with allthe information of an exercise, see /api/v2/exerciseinfo/"""- queryset = ExerciseBase.objects.accepted()+ queryset = ExerciseBase.objects.all()serializer_class = ExerciseBaseSerializerpermission_classes = (CanEditExercises, )ordering_fields = '__all__'@@ -106,7 +106,7 @@ class ExerciseTranslationViewSet(CreateUpdateModelViewSet):"""API endpoint for editing or adding exercise objects."""- queryset = Exercise.objects.accepted()+ queryset = Exercise.objects.all()permission_classes = (CanEditExercises, )serializer_class = ExerciseTranslationSerializerordering_fields = '__all__'@@ -146,7 +146,7 @@ class ExerciseViewSet(viewsets.ReadOnlyModelViewSet):API endpoint for exercise objects. For a single read-only endpoint with allthe information of an exercise, see /api/v2/exerciseinfo/"""- queryset = Exercise.objects.accepted()+ queryset = Exercise.objects.all()permission_classes = (CanEditExercises, )serializer_class = ExerciseSerializerordering_fields = '__all__'@@ -156,14 +156,13 @@ class ExerciseViewSet(viewsets.ReadOnlyModelViewSet):'exercise_base','description','language',- 'status','name',)def get_queryset(self):"""Add additional filters for fields from exercise base"""- qs = Exercise.objects.accepted()+ qs = Exercise.objects.all()category = self.request.query_params.get('category')muscles = self.request.query_params.get('muscles')@@ -222,7 +221,7 @@ def search(request):)name_lookup = Q(name__icontains=q) | Q(alias__alias__icontains=q)exercises = (- Exercise.objects.filter(name_lookup).accepted().filter(+ Exercise.objects.filter(name_lookup).all().filter(language__in=languages).order_by('exercise_base__category__name', 'name').distinct())@@ -259,7 +258,7 @@ class ExerciseInfoViewset(viewsets.ReadOnlyModelViewSet):structures for more easy parsing."""- queryset = Exercise.objects.accepted()+ queryset = Exercise.objects.all()serializer_class = ExerciseInfoSerializerordering_fields = '__all__'filterset_fields = (@@ -278,7 +277,7 @@ class ExerciseBaseInfoViewset(viewsets.ReadOnlyModelViewSet):base. Returns nested data structures for more easy and faster parsing."""- queryset = ExerciseBase.objects.accepted()+ queryset = ExerciseBase.objects.all()serializer_class = ExerciseBaseInfoSerializerordering_fields = '__all__'filterset_fields = (diff --git a/wger/exercises/fixtures/test-exercises.json b/wger/exercises/fixtures/test-exercises.jsonindex e5dbc5563..d6e01bec8 100644--- a/wger/exercises/fixtures/test-exercises.json+++ b/wger/exercises/fixtures/test-exercises.json@@ -93,7 +93,6 @@"fields": {"uuid": "acad394936fb44819a72be2ddae2bc05","category": 2,- "status": "2","creation_date": "2020-01-10","update_date": "2020-11-01T22:10:00+01:00","muscles": [@@ -112,7 +111,6 @@"fields": {"uuid": "029a6eac67f242d9b71d9d692b0a35b0","category": 2,- "status": "2","creation_date": "2014-11-01","update_date": "2018-11-01T00:00:00+01:00","muscles": [@@ -131,7 +129,6 @@"fields": {"uuid": "c2dc11e9b14a49cb9d11d1b9441f16f4","category": 3,- "status": "2","creation_date": "2020-01-10","update_date": "2020-11-01T22:10:00+01:00","muscles": [@@ -146,7 +143,6 @@"fields": {"uuid": "9838235ce38f4ca6921e9d237d8e0813","category": 3,- "status": "2","creation_date": "2022-01-10","update_date": "2022-02-02T06:45:11+01:00","muscles": [@@ -162,7 +158,6 @@"fields": {"uuid": "e9e35f0c45b14d64b00db707a94c6fb8","category": 1,- "status": "2","creation_date": "2002-08-15","update_date": "2008-08-08T08:08:08+01:00","muscles": [],@@ -174,7 +169,6 @@"model": "exercises.exercise","fields": {"uuid": "9838235ce38f4ca6921e9d237d8e0813",- "status": "2","language": 1,"exercise_base": 1,"description": "",@@ -188,7 +182,6 @@"model": "exercises.exercise","fields": {"uuid": "3275c4e6e7ba4368964b6b1a9d80ca7a",- "status": "2","language": 2,"exercise_base": 2,"description": "",@@ -202,7 +195,6 @@"model": "exercises.exercise","fields": {"uuid": "946afe7b54a644a69c36c3e31e6b4c3b",- "status": "2","language": 1,"exercise_base": 3,"description": "",@@ -216,7 +208,6 @@"model": "exercises.exercise","fields": {"uuid": "37b5813c76bd4658820a572d9dd93f31",- "status": "1","language": 1,"description": "","exercise_base": 3,@@ -231,7 +222,6 @@"model": "exercises.exercise","fields": {"uuid": "150f17eb8674450d976f4c5538479bfb",- "status": "2","language": 1,"exercise_base": 4,"description": "",@@ -245,7 +235,6 @@"model": "exercises.exercise","fields": {"uuid": "885c1110aa324235af361164347a4465",- "status": "2","language": 1,"exercise_base": 4,"description": "",@@ -259,7 +248,6 @@"model": "exercises.exercise","fields": {"uuid": "a7c662b36b474affb313a872a104dd2f",- "status": "2","language": 2,"exercise_base": 4,"description": "",@@ -273,7 +261,6 @@"model": "exercises.exercise","fields": {"uuid": "f2417bb4fa314e51bd5c425af21be468",- "status": "2","language": 2,"exercise_base": 4,"description": "",@@ -287,7 +274,6 @@"model": "exercises.exercise","fields": {"uuid": "cc3dbb66889f4deda2f0142c942c464f",- "status": "2","language": 2,"exercise_base": 4,"description": "",@@ -301,7 +287,6 @@"model": "exercises.exercise","fields": {"uuid": "283ad85ca8984a719abbc9cadd62b353",- "status": "2","language": 2,"exercise_base": 4,"description": "",diff --git a/wger/exercises/management/commands/exercise-cleanup.py b/wger/exercises/management/commands/exercise-cleanup.pyindex 3b1ec6ec6..15eb86853 100755--- a/wger/exercises/management/commands/exercise-cleanup.py+++ b/wger/exercises/management/commands/exercise-cleanup.py@@ -60,7 +60,7 @@ class Command(BaseCommand):out = []languages = Language.objects.all()- for base in ExerciseBase.objects.accepted():+ for base in ExerciseBase.objects.all():data = {'base': {diff --git a/wger/exercises/management/commands/read-exercise-cleanup.py b/wger/exercises/management/commands/read-exercise-cleanup.pyindex 6d093fc2b..7df27dbfb 100644--- a/wger/exercises/management/commands/read-exercise-cleanup.py+++ b/wger/exercises/management/commands/read-exercise-cleanup.py@@ -204,7 +204,6 @@ class Command(BaseCommand):if not exercise.id:new_exercise = True- exercise.status = Exercise.STATUS_ACCEPTEDexercise.save()# Set the aliasesdiff --git a/wger/exercises/management/commands/submitted-exercises.py b/wger/exercises/management/commands/submitted-exercises.pyindex 4bd07ce08..110e74e63 100644--- a/wger/exercises/management/commands/submitted-exercises.py+++ b/wger/exercises/management/commands/submitted-exercises.py@@ -32,7 +32,7 @@ class Command(BaseCommand):def handle(self, **options):- exercises = Exercise.objects.accepted()+ exercises = Exercise.objects.all()usernames = []for exercise in exercises:if exercise.user not in usernames:diff --git a/wger/exercises/migrations/0019_auto_20220302_2130.py b/wger/exercises/migrations/0019_auto_20220302_2130.pynew file mode 100644index 000000000..acade0ba9--- /dev/null+++ b/wger/exercises/migrations/0019_auto_20220302_2130.py@@ -0,0 +1,35 @@+# Generated by Django 3.2.10 on 2022-03-02 20:30++from django.db import migrations, models+import django.db.models.deletion+++class Migration(migrations.Migration):++ def delete_pending_exercises(apps, schema_editor):+ """+ Delete all pending exercises++ Note that we can't access STATUS_PENDING here because we are not using+ a real model.+ """+ Exercise = apps.get_model("exercises", "Exercise")+ Exercise.objects.filter(status='1').delete()++ dependencies = [+ ('exercises', '0018_auto_20220219_1336'),+ ]++ operations = [+ migrations.AlterField(+ model_name='exercisecomment',+ name='exercise',+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='exercises.exercise', verbose_name='Exercise'),+ ),+ migrations.AlterField(+ model_name='historicalexercisecomment',+ name='exercise',+ field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='exercises.exercise', verbose_name='Exercise'),+ ),+ migrations.RunPython(delete_pending_exercises),+ ]diff --git a/wger/exercises/migrations/0020_auto_20220302_2136.py b/wger/exercises/migrations/0020_auto_20220302_2136.pynew file mode 100644index 000000000..da990cf52--- /dev/null+++ b/wger/exercises/migrations/0020_auto_20220302_2136.py@@ -0,0 +1,29 @@+# Generated by Django 3.2.10 on 2022-03-02 20:36++from django.db import migrations+++class Migration(migrations.Migration):++ dependencies = [+ ('exercises', '0019_auto_20220302_2130'),+ ]++ operations = [+ migrations.RemoveField(+ model_name='exercise',+ name='status',+ ),+ migrations.RemoveField(+ model_name='exercisebase',+ name='status',+ ),+ migrations.RemoveField(+ model_name='historicalexercise',+ name='status',+ ),+ migrations.RemoveField(+ model_name='historicalexercisebase',+ name='status',+ ),+ ]diff --git a/wger/exercises/models/base.py b/wger/exercises/models/base.pyindex 17a0c3b1c..a53748442 100644--- a/wger/exercises/models/base.py+++ b/wger/exercises/models/base.py@@ -25,11 +25,8 @@ from django.utils.translation import gettext_lazy as _from simple_history.models import HistoricalRecords# wger-from wger.utils.managers import SubmissionManager-from wger.utils.models import (- AbstractLicenseModel,- AbstractSubmissionModel,-)+from wger.utils.models import AbstractLicenseModel+# Localfrom .category import ExerciseCategory@@ -38,15 +35,16 @@ from .muscle import Musclefrom .variation import Variation-class ExerciseBase(AbstractSubmissionModel, AbstractLicenseModel, models.Model):+class ExerciseBase(AbstractLicenseModel, models.Model):"""Model for an exercise base"""- objects = SubmissionManager()- """Custom manager"""-- uuid = models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='UUID')+ uuid = models.UUIDField(+ default=uuid.uuid4,+ editable=False,+ verbose_name='UUID'+ )"""Globally unique ID, to identify the base across installations"""category = models.ForeignKey(diff --git a/wger/exercises/models/exercise.py b/wger/exercises/models/exercise.pyindex 308d782bb..510cdd80d 100644--- a/wger/exercises/models/exercise.py+++ b/wger/exercises/models/exercise.py@@ -42,21 +42,13 @@ from wger.utils.cache import (delete_template_fragment_cache,reset_workout_canonical_form,)-from wger.utils.managers import SubmissionManager-from wger.utils.models import (- AbstractLicenseModel,- AbstractSubmissionModel,-)+from wger.utils.models import AbstractLicenseModel-class Exercise(AbstractSubmissionModel, AbstractLicenseModel, models.Model):+class Exercise(AbstractLicenseModel, models.Model):"""Model for an exercise"""-- objects = SubmissionManager()- """Custom manager"""-description = models.TextField(max_length=2000,verbose_name=_('Description'),@@ -200,7 +192,7 @@ class Exercise(AbstractSubmissionModel, AbstractLicenseModel, models.Model):out = []if self.exercise_base.variations:for variation in self.exercise_base.variations.exercisebase_set.all():- for exercise in variation.exercises.filter(language=self.language).accepted():+ for exercise in variation.exercises.filter(language=self.language).all():out.append(exercise)return out@@ -255,12 +247,11 @@ class Exercise(AbstractSubmissionModel, AbstractLicenseModel, models.Model):def set_author(self, request):"""- Set author and status+ Set authorThis is only used when creating exercises (via web or API)"""if request.user.has_perm('exercises.add_exercise'):- self.status = self.STATUS_ACCEPTEDif not self.license_author:self.license_author = request.get_host().split(':')[0]else:diff --git a/wger/exercises/sitemap.py b/wger/exercises/sitemap.pyindex 326baaff9..d033a0335 100644--- a/wger/exercises/sitemap.py+++ b/wger/exercises/sitemap.py@@ -26,7 +26,7 @@ class ExercisesSitemap(Sitemap):priority = 0.5def items(self):- return Exercise.objects.accepted()+ return Exercise.objects.all()def lastmod(self, obj):return obj.creation_datediff --git a/wger/exercises/templates/exercise/view.html b/wger/exercises/templates/exercise/view.htmlindex 930fa5572..6ca5014c0 100644--- a/wger/exercises/templates/exercise/view.html+++ b/wger/exercises/templates/exercise/view.html@@ -42,37 +42,6 @@ $(document).ready(function() {{# #}{% block content %}-{% if exercise.status == exercise.STATUS_PENDING %}-<div class="card text-white bg-dark mb-4">- <div class="card-header">- {% translate "Exercise is pending review" %}- </div>- <div class="card-body">- <p>{% blocktranslate %}This user submitted exercise is pending a decision to be- included in the database.{% endblocktranslate %}- {% translate "Till then, it will not be shown in the overview or the search." %}- {% if perms.exercises.add_exercise %}{% translate "Please select one of the options below." %}{% endif %}- </p>-- {% if perms.exercises.add_exercise %}- <a href="{% url 'exercise:exercise:accept' exercise.id %}" class="btn btn-secondary">- <span class="{% fa_class 'check' %}"></span>- {% translate "Accept" %}- </a>- <a href="{% url 'exercise:exercise:decline' exercise.id %}" class="btn btn-secondary">- <span class="{% fa_class 'times' %}"></span>- {% translate "Decline" %}- </a>- <a href="{% url 'exercise:exercise:delete' exercise.id %}" class="wger-modal-dialog btn btn-secondary">- <span class="{% fa_class 'trash' %}"></span>- {% translate "Delete" %}- </a>- {% endif %} {# end check permissions #}- </div>-</div>-{% endif %} {# end exercise is pending review #}--<h5 class="mt-4">{% translate "Category" %}:</h5>{% translate exercise.category.name %}diff --git a/wger/exercises/tests/test_exercise.py b/wger/exercises/tests/test_exercise.pyindex fcaa6e0de..5004d1c8b 100644--- a/wger/exercises/tests/test_exercise.py+++ b/wger/exercises/tests/test_exercise.py@@ -197,12 +197,10 @@ class ExerciseDetailTestCase(WgerTestCase):self.assertContains(response, 'Edit')self.assertContains(response, 'Delete')self.assertContains(response, 'Add new comment')- self.assertNotContains(response, 'Exercise is pending review')else:self.assertNotContains(response, 'Edit')self.assertNotContains(response, 'Delete')self.assertNotContains(response, 'Add new comment')- self.assertNotContains(response, 'Exercise is pending review')# Ensure that non-existent exercises throw a 404.response = self.client.get(reverse('exercise:exercise:view', kwargs={'id': 42}))@@ -210,7 +208,7 @@ class ExerciseDetailTestCase(WgerTestCase):def test_exercise_detail_editor(self):"""- Tests the exercise details page as a logged in user with editor rights+ Tests the exercise details page as a logged-in user with editor rights"""self.user_login('admin')@@ -327,10 +325,8 @@ class ExercisesTestCase(WgerTestCase):exercise = Exercise.objects.get(pk=exercise_id)if admin:self.assertEqual(exercise.license_author, 'testserver')- self.assertEqual(exercise.status, Exercise.STATUS_ACCEPTED)else:self.assertEqual(exercise.license_author, 'test')- self.assertEqual(exercise.status, Exercise.STATUS_PENDING)response = self.client.get(reverse('exercise:exercise:view', kwargs={'id': exercise_id}))self.assertEqual(response.status_code, 200)@@ -347,7 +343,6 @@ class ExercisesTestCase(WgerTestCase):'category': 111,'name': random_string(),'license': 1,- 'category': 111,'muscles': [1, 2]})@@ -359,7 +354,6 @@ class ExercisesTestCase(WgerTestCase):'category': 111,'name': random_string(),'license': 1,- 'category': 111,'muscles': [1, 2]})@@ -374,7 +368,6 @@ class ExercisesTestCase(WgerTestCase):'category': 1,'name': random_string(),'license': 1,- 'category': 1,'muscles': []})@@ -386,7 +379,6 @@ class ExercisesTestCase(WgerTestCase):'category': 1,'name': random_string(),'license': 1,- 'category': 1,'muscles': []})diff --git a/wger/exercises/tests/test_exercise_base.py b/wger/exercises/tests/test_exercise_base.pyindex 3b9b76f5c..0e9265fef 100644--- a/wger/exercises/tests/test_exercise_base.py+++ b/wger/exercises/tests/test_exercise_base.py@@ -47,7 +47,7 @@ class ExerciseBaseTestCase(WgerTestCase):# Even if these exercises have the same base, only the variations for# their respective languages are returned.exercise = Exercise.objects.get(pk=81)- self.assertListEqual(sorted([i.id for i in exercise.variations]), sorted([3, 35, 81]))+ self.assertListEqual(sorted([i.id for i in exercise.variations]), sorted([3, 4, 35, 81]))exercise2 = Exercise.objects.get(pk=84)self.assertEqual(sorted([i.id for i in exercise2.variations]), sorted([84, 91, 111, 126]))diff --git a/wger/exercises/tests/test_submitted_exercise.py b/wger/exercises/tests/test_submitted_exercise.pydeleted file mode 100644index d515eef45..000000000--- a/wger/exercises/tests/test_submitted_exercise.py+++ /dev/null@@ -1,206 +0,0 @@-# This file is part of wger Workout Manager.-#-# wger Workout Manager is free software: you can redistribute it and/or modify-# it under the terms of the GNU Affero General Public License as published by-# the Free Software Foundation, either version 3 of the License, or-# (at your option) any later version.-#-# wger Workout Manager is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU Affero General Public License--# Django-from django.core import mail-from django.urls import reverse--# wger-from wger.core.tests.base_testcase import (- STATUS_CODES_FAIL,- WgerTestCase,-)-from wger.exercises.models import Exercise---class ExercisesPendingTestCase(WgerTestCase):- """- Tests the pending exercises overview page- """-- def pending_overview(self, fail=False):- """- Helper function- """- response = self.client.get(reverse('exercise:exercise:pending'))- if not fail:- self.assertEqual(response.status_code, 200)- self.assertEqual(len(response.context['exercise_list']), 1)- else:- self.assertIn(response.status_code, STATUS_CODES_FAIL)-- def test_pending_overview_admin(self):- """- Tests the pending exercises overview page as an admin user- """-- self.user_login('admin')- self.pending_overview()-- def test_pending_overview_user(self):- """- Tests the pending exercises overview page as a regular user- """-- self.user_login('test')- self.pending_overview(fail=True)-- def test_pending_overview_logged_out(self):- """- Tests the pending exercises overview page as a logged out user- """-- self.pending_overview(fail=True)---class ExercisesPendingDetailTestCase(WgerTestCase):- """- Tests the detail page of a pending exercise- """-- def pending_view(self, fail=False):- """- Helper function- """- response = self.client.get(reverse('exercise:exercise:view', kwargs={'id': 4}))- self.assertContains(response, 'Exercise is pending review')-- if not fail:- self.assertEqual(response.status_code, 200)- self.assertContains(response, 'Please select one of the options below')- self.assertContains(response, 'Accept')- self.assertContains(response, 'Decline')- else:- self.assertNotContains(response, 'Please select one of the options below')- self.assertNotContains(response, 'Accept')- self.assertNotContains(response, 'Decline')-- def test_pending_view_admin(self):- """- Tests the detail page of a pending exercise as an admin user- """-- self.user_login('admin')- self.pending_view()-- def test_pending_view_user(self):- """- Tests the detail page of a pending exercise as a regular user- """-- self.user_login('test')- self.pending_view(fail=True)-- def test_pending_view_logged_out(self):- """- Tests the detail page of a pending exercise as a logged out user- """-- self.pending_view(fail=True)---class ExerciseAcceptTestCase(WgerTestCase):- """- Tests accepting a user submitted exercise- """-- def accept(self, fail=False):- """- Helper function- """- exercise = Exercise.objects.get(pk=4)- self.assertEqual(exercise.status, Exercise.STATUS_PENDING)- response = self.client.get(reverse('exercise:exercise:accept', kwargs={'pk': 4}))- exercise = Exercise.objects.get(pk=4)-- self.assertEqual(response.status_code, 302)-- if not fail:- self.assertEqual(exercise.status, Exercise.STATUS_ACCEPTED)- response = self.client.get(response['Location'])- self.assertEqual(response.status_code, 200)- self.assertEqual(len(mail.outbox), 1)- else:- self.assertEqual(exercise.status, Exercise.STATUS_PENDING)- self.assertEqual(len(mail.outbox), 0)-- def test_accept_admin(self):- """- Tests accepting a user submitted exercise as an admin user- """-- self.user_login('admin')- self.accept()-- def test_accept_user(self):- """- Tests accepting a user submitted exercise as a regular user- """-- self.user_login('test')- self.accept(fail=True)-- def test_accept_logged_out(self):- """- Tests accepting a user submitted exercise as a logged out user- """-- self.accept(fail=True)---class ExerciseRejectTestCase(WgerTestCase):- """- Tests rejecting a user submitted exercise- """-- def reject(self, fail=False):- """- Helper function- """- exercise = Exercise.objects.get(pk=4)- self.assertEqual(exercise.status, Exercise.STATUS_PENDING)- response = self.client.get(reverse('exercise:exercise:decline', kwargs={'pk': 4}))- exercise = Exercise.objects.get(pk=4)- self.assertEqual(response.status_code, 302)-- if not fail:- self.assertEqual(exercise.status, Exercise.STATUS_DECLINED)- response = self.client.get(response['Location'])- self.assertEqual(response.status_code, 200)-- else:- self.assertEqual(exercise.status, Exercise.STATUS_PENDING)-- def test_reject_admin(self):- """- Tests rejecting a user submitted exercise as an admin user- """-- self.user_login('admin')- self.reject()-- def test_reject_user(self):- """- Tests rejecting a user submitted exercise as a regular user- """-- self.user_login('test')- self.reject(fail=True)-- def test_reject_logged_out(self):- """- Tests rejecting a user submitted exercise as a logged out user- """-- self.reject(fail=True)diff --git a/wger/exercises/urls.py b/wger/exercises/urls.pyindex 93c807c41..4af1cf8d5 100644--- a/wger/exercises/urls.py+++ b/wger/exercises/urls.py@@ -232,16 +232,6 @@ patterns_exercise = [exercises.PendingExerciseListView.as_view(),name='pending',),- path(- '<int:pk>/accept/',- exercises.accept,- name='accept',- ),- path(- '<int:pk>/decline/',- exercises.decline,- name='decline',- ),]urlpatterns = [diff --git a/wger/exercises/views/exercises.py b/wger/exercises/views/exercises.pyindex 7032ffadc..06e545426 100644--- a/wger/exercises/views/exercises.py+++ b/wger/exercises/views/exercises.py@@ -114,7 +114,7 @@ class ExerciseListView(ListView):Filter to only active exercises in the configured languages"""languages = load_item_languages(LanguageConfig.SHOW_ITEM_EXERCISES)- return Exercise.objects.accepted() \+ return Exercise.objects.all() \.filter(language__in=languages) \.order_by('exercise_base__category__id') \.select_related()@@ -218,7 +218,7 @@ class ExerciseForm(ModelForm):if not self.instance.id:language = load_language()- exercises = Exercise.objects.accepted() \+ exercises = Exercise.objects.all() \.filter(language=language)for exercise in exercises:exercise_name = str(exercise)@@ -313,7 +313,7 @@ class ExerciseAddView(ExercisesEditAddView, LoginRequiredMixin, CreateView):def form_valid(self, form):"""- Set language, author and status+ Set language and author"""form.instance.language = load_language()form.instance.set_author(self.request)@@ -448,28 +448,3 @@ class PendingExerciseListView(LoginRequiredMixin, PermissionRequiredMixin, ListV"""return Exercise.objects.pending().order_by('-creation_date')--@permission_required('exercises.add_exercise')-def accept(request, pk):- """- Accepts a pending user submitted exercise and emails the user, if possible- """- exercise = get_object_or_404(Exercise, pk=pk)- exercise.status = Exercise.STATUS_ACCEPTED- exercise.save()- exercise.send_email(request)- messages.success(request, _('Exercise was successfully added to the general database'))-- return HttpResponseRedirect(exercise.get_absolute_url())---@permission_required('exercises.add_exercise')-def decline(request, pk):- """- Declines and deletes a pending user submitted exercise- """- exercise = get_object_or_404(Exercise, pk=pk)- exercise.status = Exercise.STATUS_DECLINED- exercise.save()- messages.success(request, _('Exercise was successfully marked as rejected'))- return HttpResponseRedirect(exercise.get_absolute_url())