Self hosted FLOSS fitness/workout, nutrition and weight tracker
(bug) Resets exercise cache after muscle deletion
pythonGeek1cdb66c1f8a2
diff --git a/wger/exercises/models.py b/wger/exercises/models.pyindex 36653d90f..b6778b73f 100644--- a/wger/exercises/models.py+++ b/wger/exercises/models.py@@ -21,6 +21,7 @@ import loggingimport bleachfrom django.db import models+from django.db.models import Qfrom django.template.loader import render_to_stringfrom django.template.defaultfilters import slugify # django.utils.text.slugify in django 1.5!from django.contrib.auth.models import User@@ -77,6 +78,20 @@ class Muscle(models.Model):'''return False+ def delete(self, *args, **kwargs):+ '''+ Clear template cache and delete a muscle+ '''+ exercises = Exercise.objects.filter(Q(muscles=self) | Q(muscles_secondary=self)).all()++ for exercise in exercises:+ for language in Language.objects.all():+ delete_template_fragment_cache('exercise-detail-muscles',+ exercise.id, language.id)++ super(Muscle, self).delete(*args, **kwargs)++@python_2_unicode_compatibleclass Equipment(models.Model):