Self hosted FLOSS fitness/workout, nutrition and weight tracker
Remove unused exercises views
Roland Geider45109cf0079a
diff --git a/wger/exercises/tests/test_exercise_comments.py b/wger/exercises/tests/test_exercise_comments.pyindex 0ca16b7fe..709cd6f33 100644--- a/wger/exercises/tests/test_exercise_comments.py+++ b/wger/exercises/tests/test_exercise_comments.py@@ -42,118 +42,6 @@ class ExerciseCommentRepresentationTestCase(WgerTestCase):self.assertEqual("{0}".format(ExerciseComment.objects.get(pk=1)), 'test 123')-class AddExerciseCommentTestCase(WgerAddTestCase):- """- Tests adding a comment to an exercise- """-- object_class = ExerciseComment- url = reverse('exercise:comment:add', kwargs={'exercise_pk': 1})- user_fail = False- data = {'comment': 'a new cool comment'}---class EditExerciseCommentTestCase(WgerEditTestCase):- """- Tests editing a comment to an exercise- """-- object_class = ExerciseComment- url = 'exercise:comment:edit'- pk = 1- data = {'comment': 'an edited comment'}---class ExercisecommentsTestCase(WgerTestCase):-- def exercise_delete_comment(self, fail=True):- """- Tests the deletion of exercise comments- """-- # Load the exercise- exercise_1 = Exercise.objects.get(pk=1)-- # Comments are loaded- comments = exercise_1.exercisecomment_set.all()- comment_1: ExerciseComment = comments[0]- self.assertEqual(comment_1.id, 1)- self.assertEqual(comment_1.comment, "test 123")- self.assertEqual(len(comments), 1)-- # Delete the comment- response = self.client.post(reverse('exercise:comment:delete', kwargs={'id': 1}))- comments = exercise_1.exercisecomment_set.all()-- self.assertEqual(response.status_code, 302)- if fail:- comments = exercise_1.exercisecomment_set.all()- self.assertEqual(len(comments), 1)-- else:- self.assertEqual(len(comments), 0)-- def test_exercise_delete_comment_no_authorized(self):- """- Tests the exercise comments- """-- self.user_login('test')- self.exercise_delete_comment(fail=True)- self.user_logout()-- def test_exercise_delete_comment_not_logged_in(self):- """- Tests the exercise comments- """-- self.exercise_delete_comment(fail=True)-- def test_exercise_delete_comment_authorized(self):- """- Tests the exercise comments- """-- self.user_login()- self.exercise_delete_comment(fail=False)---class WorkoutCacheTestCase(WgerTestCase):- """- Workout cache test case- """-- def test_canonical_form_cache_save(self):- """- Tests the workout cache when saving- """- comment = ExerciseComment.objects.get(pk=1)- for setting in comment.exercise.exercise_base.setting_set.all():- setting.set.exerciseday.training.canonical_representation- workout_id = setting.set.exerciseday.training_id- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(workout_id)))-- comment.save()- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(workout_id)))-- def test_canonical_form_cache_delete(self):- """- Tests the workout cache when deleting- """- comment = ExerciseComment.objects.get(pk=1)-- workout_ids = []- for setting in comment.exercise.exercise_base.setting_set.all():- workout_id = setting.set.exerciseday.training_id- workout_ids.append(workout_id)- setting.set.exerciseday.training.canonical_representation- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(workout_id)))-- comment.delete()- for workout_id in workout_ids:- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(workout_id)))--class ExerciseCommentApiTestCase(ExerciseCrudApiTestCase):"""Tests the exercise comment overview resourcediff --git a/wger/exercises/tests/test_exercise_translation.py b/wger/exercises/tests/test_exercise_translation.pyindex 26f5e197c..124149051 100644--- a/wger/exercises/tests/test_exercise_translation.py+++ b/wger/exercises/tests/test_exercise_translation.py@@ -111,18 +111,6 @@ class ExercisesTestCase(WgerTestCase):self.assertEqual(len(exercise.history.all()), 1)-class DeleteExercisesTestCase(WgerDeleteTestCase):- """- Exercise test case- """-- object_class = Exercise- url = 'exercise:exercise:delete'- pk = 2- user_success = 'admin'- user_fail = 'test'--class MuscleTemplateTagTest(WgerTestCase):def test_render_main_muscles(self):diff --git a/wger/exercises/urls.py b/wger/exercises/urls.pyindex bacbc9514..c6be132ce 100644--- a/wger/exercises/urls.py+++ b/wger/exercises/urls.py@@ -26,7 +26,6 @@ from django.views.generic import TemplateView# wgerfrom wger.exercises.views import (categories,- comments,equipment,exercises,history,@@ -68,25 +67,6 @@ patterns_muscle = [),]-# sub patterns for exercise comments-patterns_comment = [- path(- '<int:exercise_pk>/comment/add/',- comments.ExerciseCommentAddView.as_view(),- name='add',- ),- path(- '<int:pk>/edit/',- comments.ExerciseCommentEditView.as_view(),- name='edit',- ),- path(- '<int:id>/delete/',- comments.delete,- name='delete',- ),-]-# sub patterns for categoriespatterns_category = [path(@@ -167,16 +147,10 @@ patterns_exercise = [TemplateView.as_view(template_name='exercise/contribute.html'),name='contribute',),- path(- '<int:pk>/delete/',- exercises.ExerciseDeleteView.as_view(),- name='delete',- ),]urlpatterns = [path('muscle/', include((patterns_muscle, 'muscle'), namespace="muscle")),- path('comment/', include((patterns_comment, 'comment'), namespace="comment")),path('category/', include((patterns_category, 'category'), namespace="category")),path('equipment/', include((patterns_equipment, 'equipment'), namespace="equipment")),path('history/', include((patterns_history, 'history'), namespace="history")),diff --git a/wger/exercises/views/comments.py b/wger/exercises/views/comments.pydeleted file mode 100644index 4eff56858..000000000--- a/wger/exercises/views/comments.py+++ /dev/null@@ -1,100 +0,0 @@-# -*- coding: utf-8 -*---# 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--# Standard Library-import logging--# Django-from django.contrib.auth.decorators import permission_required-from django.contrib.auth.mixins import (- LoginRequiredMixin,- PermissionRequiredMixin,-)-from django.http import HttpResponseRedirect-from django.shortcuts import get_object_or_404-from django.urls import reverse-from django.utils.translation import gettext_lazy-from django.views.generic import (- CreateView,- UpdateView,-)--# wger-from wger.exercises.forms import CommentForm-from wger.exercises.models import (- Exercise,- ExerciseComment,-)-from wger.utils.generic_views import WgerFormMixin---logger = logging.getLogger(__name__)--# ************************-# Exercise comments-# ************************---class ExerciseCommentEditView(- WgerFormMixin,- LoginRequiredMixin,- PermissionRequiredMixin,- UpdateView,-):- """- Generic view to update an existing exercise comment- """-- model = ExerciseComment- form_class = CommentForm- title = gettext_lazy('Edit')- permission_required = 'exercises.change_exercisecomment'-- def get_success_url(self):- return reverse('exercise:exercise:view', kwargs={'id': self.object.exercise.id})---class ExerciseCommentAddView(- WgerFormMixin,- LoginRequiredMixin,- PermissionRequiredMixin,- CreateView,-):- """- Generic view to add a new exercise comment- """-- model = ExerciseComment- form_class = CommentForm- title = gettext_lazy('Add exercise comment')- permission_required = 'exercises.add_exercisecomment'-- def form_valid(self, form):- form.instance.exercise = Exercise.objects.get(pk=self.kwargs['exercise_pk'])- return super(ExerciseCommentAddView, self).form_valid(form)-- def get_success_url(self):- return reverse('exercise:exercise:view', kwargs={'id': self.object.exercise.id})---@permission_required('exercises.delete_exercisecomment')-def delete(request, id):- # Load the comment- comment = get_object_or_404(ExerciseComment, pk=id)- exercise_id = comment.exercise.id- comment.delete()-- return HttpResponseRedirect(reverse('exercise:exercise:view', kwargs={'id': exercise_id}))diff --git a/wger/exercises/views/exercises.py b/wger/exercises/views/exercises.pyindex 8be0a4821..78d77b2a0 100644--- a/wger/exercises/views/exercises.py+++ b/wger/exercises/views/exercises.py@@ -166,28 +166,3 @@ class ExerciseForm(ModelForm):},)return name---class ExerciseDeleteView(- WgerDeleteMixin,- LoginRequiredMixin,- PermissionRequiredMixin,- DeleteView,-):- """- Generic view to delete an existing exercise- """-- model = Exercise- success_url = reverse_lazy('exercise:exercise:overview')- delete_message_extra = gettext_lazy('This will delete the exercise from all workouts.')- messages = gettext_lazy('Successfully deleted')- permission_required = 'exercises.delete_exercise'-- def get_context_data(self, **kwargs):- """- Send some additional data to the template- """- context = super(ExerciseDeleteView, self).get_context_data(**kwargs)- context['title'] = _('Delete {0}?').format(self.object.name)- return contextdiff --git a/wger/utils/tests/test_middleware.py b/wger/utils/tests/test_middleware.pyindex 1e06f5a57..e7f907135 100644--- a/wger/utils/tests/test_middleware.py+++ b/wger/utils/tests/test_middleware.py@@ -75,5 +75,5 @@ class RobotsExclusionMiddlewareTestCase(WgerTestCase):response = self.client.get(reverse('exercise:exercise:overview'))self.assertFalse(response.get('X-Robots-Tag'))- response = self.client.get(reverse('exercise:exercise:view', kwargs={'id': 1}))+ response = self.client.get(reverse('exercise:exercise:view-base', kwargs={'pk': 1}))self.assertFalse(response.get('X-Robots-Tag'))