Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Remove more unused code

Roland Geiderf586f505a0b5
diff --git a/wger/core/templates/tags/muscles.html b/wger/core/templates/tags/muscles.html
deleted file mode 100644
index 6d682f9ea..000000000
--- a/wger/core/templates/tags/muscles.html
+++ /dev/null
@@ -1,6 +0,0 @@
-{% load static %}
-{% if backgrounds %}
-<div class="muscle-background mx-auto"
- style="background-image: {% for background in backgrounds %}url({{ background }}){% if not forloop.last %},{% endif %}{% endfor %};">
-</div>
-{% endif %}
diff --git a/wger/core/templatetags/wger_extras.py b/wger/core/templatetags/wger_extras.py
index 500476a28..e6d3244f9 100644
--- a/wger/core/templatetags/wger_extras.py
+++ b/wger/core/templatetags/wger_extras.py
@@ -34,22 +34,9 @@ from wger.utils.constants import (
)
from wger.utils.language import get_language_data
-
register = template.Library()
[email protected](name='get_current_settings')
-def get_current_settings(exercise, set_id):
- """
- Does a filter on the sets
-
- We need to do this here because it's not possible to pass arguments to function in
- the template, and we are only interested on the settings that belong to the current
- set
- """
- return exercise.exercise_base.setting_set.filter(set_id=set_id)
-
-
@register.inclusion_tag('tags/pagination.html')
def pagination(paginator, page):
"""
@@ -80,37 +67,6 @@ def pagination(paginator, page):
return {'page': page, 'page_range': page_range}
[email protected]_tag('tags/muscles.html')
-def render_muscles(muscles=None, muscles_sec=None):
- """
- Renders the given muscles
- """
- out = {'backgrounds': []}
- if not muscles and not muscles_sec:
- return out
-
- out_main = []
- if muscles:
- out_main = muscles if isinstance(muscles, Iterable) else [muscles]
-
- out_secondary = []
- if muscles_sec:
- out_secondary = muscles_sec if isinstance(muscles_sec, Iterable) else [muscles_sec]
-
- if out_main:
- front_back = 'front' if out_main[0].is_front else 'back'
- else:
- front_back = 'front' if out_secondary[0].is_front else 'back'
-
- out['backgrounds'] = (
- [i.image_url_main for i in out_main]
- + [i.image_url_secondary for i in out_secondary]
- + [static(f'images/muscles/muscular_system_{front_back}.svg')]
- )
-
- return out
-
-
@register.inclusion_tag('tags/language_select.html', takes_context=True)
def language_select(context, language):
"""
diff --git a/wger/exercises/tests/test_exercise_translation.py b/wger/exercises/tests/test_exercise_translation.py
index 4106bd519..99822f6e4 100644
--- a/wger/exercises/tests/test_exercise_translation.py
+++ b/wger/exercises/tests/test_exercise_translation.py
@@ -106,111 +106,6 @@ class ExercisesTestCase(WgerTestCase):
self.assertEqual(len(translation.history.all()), 1)
-class MuscleTemplateTagTest(WgerTestCase):
- def test_render_main_muscles(self):
- """
- Test that the tag renders only the main muscles
- """
-
- context = Context({'muscles': Muscle.objects.get(pk=2)})
- template = Template('{% load wger_extras %}{% render_muscles muscles %}')
- rendered_template = template.render(context)
- self.assertIn('images/muscles/main/muscle-2.svg', rendered_template)
- self.assertNotIn('images/muscles/secondary/', rendered_template)
- self.assertIn('images/muscles/muscular_system_back.svg', rendered_template)
-
- def test_render_main_muscles_empty_secondary(self):
- """
- Test that the tag works when giben main muscles and empty secondary ones
- """
-
- context = Context({'muscles': Muscle.objects.get(pk=2), 'muscles_sec': []})
- template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
- rendered_template = template.render(context)
- self.assertIn('images/muscles/main/muscle-2.svg', rendered_template)
- self.assertNotIn('images/muscles/secondary/', rendered_template)
- self.assertIn('images/muscles/muscular_system_back.svg', rendered_template)
-
- def test_render_secondary_muscles(self):
- """
- Test that the tag renders only the secondary muscles
- """
-
- context = Context({'muscles': Muscle.objects.get(pk=1)})
- template = Template('{% load wger_extras %}{% render_muscles muscles_sec=muscles %}')
- rendered_template = template.render(context)
- self.assertIn('images/muscles/secondary/muscle-1.svg', rendered_template)
- self.assertNotIn('images/muscles/main/', rendered_template)
- self.assertIn('images/muscles/muscular_system_front.svg', rendered_template)
-
- def test_render_secondary_muscles_empty_primary(self):
- """
- Test that the tag works when given secondary muscles and empty main ones
- """
-
- context = Context({'muscles_sec': Muscle.objects.get(pk=1), 'muscles': []})
- template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
- rendered_template = template.render(context)
- self.assertIn('images/muscles/secondary/muscle-1.svg', rendered_template)
- self.assertNotIn('images/muscles/main/', rendered_template)
- self.assertIn('images/muscles/muscular_system_front.svg', rendered_template)
-
- def test_render_secondary_muscles_list(self):
- """
- Test that the tag works when given a list for secondary muscles and empty main ones
- """
-
- context = Context({'muscles_sec': Muscle.objects.filter(is_front=True), 'muscles': []})
- template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
- rendered_template = template.render(context)
- self.assertIn('images/muscles/secondary/muscle-1.svg', rendered_template)
- self.assertNotIn('images/muscles/secondary/muscle-2.svg', rendered_template)
- self.assertNotIn('images/muscles/secondary/muscle-3.svg', rendered_template)
- self.assertIn('images/muscles/muscular_system_front.svg', rendered_template)
- self.assertNotIn('images/muscles/muscular_system_back.svg', rendered_template)
-
- def test_render_muscle_list(self):
- """
- Test that the tag works when given a list for main and secondary muscles
- """
-
- context = Context(
- {
- 'muscles_sec': Muscle.objects.filter(id__in=[5, 6]),
- 'muscles': Muscle.objects.filter(id__in=[1, 4]),
- }
- )
- template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
- rendered_template = template.render(context)
- self.assertIn('images/muscles/main/muscle-1.svg', rendered_template)
- self.assertNotIn('images/muscles/main/muscle-2.svg', rendered_template)
- self.assertNotIn('images/muscles/main/muscle-3.svg', rendered_template)
- self.assertIn('images/muscles/main/muscle-4.svg', rendered_template)
- self.assertIn('images/muscles/secondary/muscle-5.svg', rendered_template)
- self.assertIn('images/muscles/secondary/muscle-6.svg', rendered_template)
- self.assertIn('images/muscles/muscular_system_front.svg', rendered_template)
- self.assertNotIn('images/muscles/muscular_system_back.svg', rendered_template)
-
- def test_render_empty(self):
- """
- Test that the tag works when given empty input
- """
-
- context = Context({'muscles': [], 'muscles_sec': []})
- template = Template('{% load wger_extras %}{% render_muscles muscles muscles_sec %}')
- rendered_template = template.render(context)
- self.assertEqual(rendered_template, '\n\n')
-
- def test_render_no_parameters(self):
- """
- Test that the tag works when given no parameters
- """
-
- template = Template('{% load wger_extras %}{% render_muscles %}')
- rendered_template = template.render(Context({}))
- self.assertEqual(rendered_template, '\n\n')
-
-
# TODO: fix test, all registered users can upload exercises
class ExerciseApiTestCase(
api_base_test.BaseTestCase, api_base_test.ApiBaseTestCase, api_base_test.ApiGetTestCase