Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Remove the cache resetting code for the canonical representation

Roland Geider253dea51904a
diff --git a/wger/core/management/commands/clear-cache.py b/wger/core/management/commands/clear-cache.py
index 0dc4b01b8..9ce96555c 100644
--- a/wger/core/management/commands/clear-cache.py
+++ b/wger/core/management/commands/clear-cache.py
@@ -30,7 +30,6 @@ from wger.manager.models import (
)
from wger.utils.cache import (
delete_template_fragment_cache,
- reset_workout_canonical_form,
reset_workout_log,
)
@@ -53,14 +52,6 @@ class Command(BaseCommand):
help='Clear only template caches'
)
- parser.add_argument(
- '--clear-workout-cache',
- action='store_true',
- dest='clear_workout',
- default=False,
- help='Clear only the workout canonical view'
- )
-
parser.add_argument(
'--clear-all',
action='store_true',
@@ -112,11 +103,6 @@ class Command(BaseCommand):
delete_template_fragment_cache('exercise-overview', language.id)
delete_template_fragment_cache('equipment-overview', language.id)
- # Workout canonical form
- if options['clear_workout']:
- for w in Workout.objects.all():
- reset_workout_canonical_form(w.pk)
-
# Nuclear option, clear all
if options['clear_all']:
cache.clear()
diff --git a/wger/exercises/models/comment.py b/wger/exercises/models/comment.py
index 2fa0179fb..e0c15ca4b 100644
--- a/wger/exercises/models/comment.py
+++ b/wger/exercises/models/comment.py
@@ -18,9 +18,6 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
-# wger
-from wger.utils.cache import reset_workout_canonical_form
-
# Local
from .exercise import Exercise
@@ -47,24 +44,6 @@ class ExerciseComment(models.Model):
"""
return self.comment
- def save(self, *args, **kwargs):
- """
- Reset cached workouts
- """
- for setting in self.exercise.setting_set.all():
- reset_workout_canonical_form(setting.set.exerciseday.training_id)
-
- super(ExerciseComment, self).save(*args, **kwargs)
-
- def delete(self, *args, **kwargs):
- """
- Reset cached workouts
- """
- for setting in self.exercise.setting_set.all():
- reset_workout_canonical_form(setting.set.exerciseday.training.pk)
-
- super(ExerciseComment, self).delete(*args, **kwargs)
-
def get_owner_object(self):
"""
Comment has no owner information
diff --git a/wger/exercises/models/exercise.py b/wger/exercises/models/exercise.py
index 8b3302017..f5fc2c4e5 100644
--- a/wger/exercises/models/exercise.py
+++ b/wger/exercises/models/exercise.py
@@ -36,10 +36,7 @@ import bleach
# wger
from wger.core.models import Language
from wger.exercises.models import ExerciseBase
-from wger.utils.cache import (
- delete_template_fragment_cache,
- reset_workout_canonical_form,
-)
+from wger.utils.cache import delete_template_fragment_cache
from wger.utils.helpers import smart_capitalize
from wger.utils.managers import SubmissionManager
from wger.utils.models import (
@@ -133,10 +130,6 @@ class Exercise(AbstractSubmissionModel, AbstractLicenseModel, models.Model):
delete_template_fragment_cache('exercise-overview', language.id)
delete_template_fragment_cache('equipment-overview', language.id)
- # Cached workouts
- for setting in self.setting_set.all():
- reset_workout_canonical_form(setting.set.exerciseday.training_id)
-
def delete(self, *args, **kwargs):
"""
Reset all cached infos
@@ -148,10 +141,6 @@ class Exercise(AbstractSubmissionModel, AbstractLicenseModel, models.Model):
delete_template_fragment_cache('exercise-overview', language.id)
delete_template_fragment_cache('equipment-overview', language.id)
- # Cached workouts
- for setting in self.setting_set.all():
- reset_workout_canonical_form(setting.set.exerciseday.training.pk)
-
super(Exercise, self).delete(*args, **kwargs)
def __str__(self):
diff --git a/wger/exercises/tests/test_exercise.py b/wger/exercises/tests/test_exercise.py
index ac009cda1..346920287 100644
--- a/wger/exercises/tests/test_exercise.py
+++ b/wger/exercises/tests/test_exercise.py
@@ -646,42 +646,6 @@ class MuscleTemplateTagTest(WgerTestCase):
self.assertEqual(rendered_template, "\n\n")
-class WorkoutCacheTestCase(WgerTestCase):
- """
- Workout cache test case
- """
-
- def test_canonical_form_cache_save(self):
- """
- Tests the workout cache when saving
- """
- exercise = Exercise.objects.get(pk=2)
- for setting in exercise.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)))
-
- exercise.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
- """
- exercise = Exercise.objects.get(pk=2)
-
- workout_ids = []
- for setting in exercise.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)))
-
- exercise.delete()
- for workout_id in workout_ids:
- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(workout_id)))
-
-
# TODO: fix test, all registered users can upload exercises
class ExerciseApiTestCase(
api_base_test.BaseTestCase, api_base_test.ApiBaseTestCase, api_base_test.ApiGetTestCase
diff --git a/wger/exercises/tests/test_exercise_comments.py b/wger/exercises/tests/test_exercise_comments.py
index 052406cb6..121808472 100644
--- a/wger/exercises/tests/test_exercise_comments.py
+++ b/wger/exercises/tests/test_exercise_comments.py
@@ -118,42 +118,6 @@ class ExercisecommentsTestCase(WgerTestCase):
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.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.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(api_base_test.ApiBaseResourceTestCase):
"""
Tests the exercise comment overview resource
diff --git a/wger/manager/models.py b/wger/manager/models.py
index 6cf6ddc87..4d2850252 100644
--- a/wger/manager/models.py
+++ b/wger/manager/models.py
@@ -42,13 +42,8 @@ from wger.core.models import (
WeightUnit,
)
from wger.exercises.models import Exercise
-from wger.utils.cache import (
- cache_mapper,
- reset_workout_canonical_form,
- reset_workout_log,
-)
+from wger.utils.cache import reset_workout_log
from wger.utils.fields import Html5DateField
-from wger.utils.helpers import normalize_decimal
class WorkoutSession(models.Model):
diff --git a/wger/manager/models/day.py b/wger/manager/models/day.py
index 704ca7137..3a349c239 100644
--- a/wger/manager/models/day.py
+++ b/wger/manager/models/day.py
@@ -20,7 +20,6 @@ from django.utils.translation import gettext_lazy as _
# wger
from wger.core.models import DaysOfWeek
-from wger.utils.cache import reset_workout_canonical_form
# Local
from ..helpers import MusclesHelper
@@ -64,22 +63,6 @@ class Day(models.Model):
"""
return self.day.all()[0].pk
- def save(self, *args, **kwargs):
- """
- Reset all cached infos
- """
-
- reset_workout_canonical_form(self.training_id)
- super(Day, self).save(*args, **kwargs)
-
- def delete(self, *args, **kwargs):
- """
- Reset all cached infos
- """
-
- reset_workout_canonical_form(self.training_id)
- super(Day, self).delete(*args, **kwargs)
-
@property
def muscles(self) -> MusclesHelper:
"""All trained muscles by the exercises in this day"""
diff --git a/wger/manager/models/set.py b/wger/manager/models/set.py
index a2b06fced..e2332b4e4 100644
--- a/wger/manager/models/set.py
+++ b/wger/manager/models/set.py
@@ -27,7 +27,6 @@ from django.utils.translation import gettext_lazy as _
# wger
from wger.exercises.models import Exercise
-from wger.utils.cache import reset_workout_canonical_form
from wger.utils.helpers import normalize_decimal
# Local
@@ -77,22 +76,6 @@ class Set(models.Model):
"""
return self.exerciseday.training
- def save(self, *args, **kwargs):
- """
- Reset all cached infos
- """
-
- reset_workout_canonical_form(self.exerciseday.training_id)
- super(Set, self).save(*args, **kwargs)
-
- def delete(self, *args, **kwargs):
- """
- Reset all cached infos
- """
-
- reset_workout_canonical_form(self.exerciseday.training_id)
- super(Set, self).delete(*args, **kwargs)
-
@property
def exercises(self) -> typing.List[Exercise]:
"""Returns the exercises for this set"""
diff --git a/wger/manager/models/setting.py b/wger/manager/models/setting.py
index d9da49c34..285e34add 100644
--- a/wger/manager/models/setting.py
+++ b/wger/manager/models/setting.py
@@ -28,7 +28,6 @@ from wger.core.models import (
WeightUnit,
)
from wger.exercises.models import Exercise
-from wger.utils.cache import reset_workout_canonical_form
# Local
from ..consts import RIR_OPTIONS
@@ -112,7 +111,6 @@ class Setting(models.Model):
"""
Reset cache
"""
- reset_workout_canonical_form(self.set.exerciseday.training_id)
# If the user selected "Until Failure", do only 1 "repetition",
# everythin else doesn't make sense.
@@ -120,14 +118,6 @@ class Setting(models.Model):
self.reps = 1
super(Setting, self).save(*args, **kwargs)
- def delete(self, *args, **kwargs):
- """
- Reset cache
- """
-
- reset_workout_canonical_form(self.set.exerciseday.training_id)
- super(Setting, self).delete(*args, **kwargs)
-
def get_owner_object(self):
"""
Returns the object that has owner information
diff --git a/wger/manager/models/workout.py b/wger/manager/models/workout.py
index 928478a17..2e1934c7d 100644
--- a/wger/manager/models/workout.py
+++ b/wger/manager/models/workout.py
@@ -23,10 +23,6 @@ from django.utils.translation import gettext_lazy as _
# wger
from wger.manager.helpers import MusclesHelper
-from wger.utils.cache import (
- cache_mapper,
- reset_workout_canonical_form,
-)
class Workout(models.Model):
@@ -77,20 +73,6 @@ class Workout(models.Model):
else:
return "{0} ({1})".format(_('Workout'), self.creation_date)
- def save(self, *args, **kwargs):
- """
- Reset all cached infos
- """
- reset_workout_canonical_form(self.id)
- super(Workout, self).save(*args, **kwargs)
-
- def delete(self, *args, **kwargs):
- """
- Reset all cached infos
- """
- reset_workout_canonical_form(self.id)
- super(Workout, self).delete(*args, **kwargs)
-
def get_owner_object(self):
"""
Returns the object that has owner information
diff --git a/wger/manager/tests/test_day.py b/wger/manager/tests/test_day.py
index b467cb11a..451ff3146 100644
--- a/wger/manager/tests/test_day.py
+++ b/wger/manager/tests/test_day.py
@@ -157,34 +157,6 @@ class RenderWorkoutDayTestCase(WgerTestCase):
self.render_day(fail=True)
-class WorkoutCacheTestCase(WgerTestCase):
- """
- Workout cache test case
- """
-
- def test_canonical_form_cache_save(self):
- """
- Tests the workout cache when saving
- """
- day = Day.objects.get(pk=1)
- day.canonical_representation
- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(day.training_id)))
-
- day.save()
- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(day.training_id)))
-
- def test_canonical_form_cache_delete(self):
- """
- Tests the workout cache when deleting
- """
- day = Day.objects.get(pk=1)
- day.canonical_representation
- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(day.training_id)))
-
- day.delete()
- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(day.training_id)))
-
-
class DayTestCase(WgerTestCase):
"""
Other tests
diff --git a/wger/manager/tests/test_set.py b/wger/manager/tests/test_set.py
index 5ce9151cb..23cfd00d3 100644
--- a/wger/manager/tests/test_set.py
+++ b/wger/manager/tests/test_set.py
@@ -360,64 +360,6 @@ class SetEditEditTestCase(WgerTestCase):
self.edit_set(fail=False)
-class SetWorkoutCacheTestCase(WgerTestCase):
- """
- Workout cache test case
- """
-
- def test_canonical_form_cache_save(self):
- """
- Tests the workout cache when saving
- """
- set = Set.objects.get(pk=1)
- set.exerciseday.training.canonical_representation
- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(set.exerciseday.training_id)))
-
- set.save()
- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(set.exerciseday.training_id)))
-
- def test_canonical_form_cache_delete(self):
- """
- Tests the workout cache when deleting
- """
- set = Set.objects.get(pk=1)
- set.exerciseday.training.canonical_representation
- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(set.exerciseday.training_id)))
-
- set.delete()
- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(set.exerciseday.training_id)))
-
-
-class SettingWorkoutCacheTestCase(WgerTestCase):
- """
- Workout cache test case
- """
-
- def test_canonical_form_cache_save(self):
- """
- Tests the workout cache when saving
- """
- setting = Setting.objects.get(pk=1)
- workout_id = setting.set.exerciseday.training_id
- setting.set.exerciseday.training.canonical_representation
- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(workout_id)))
-
- setting.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
- """
- setting = Setting.objects.get(pk=1)
- workout_id = setting.set.exerciseday.training_id
- setting.set.exerciseday.training.canonical_representation
- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(workout_id)))
-
- setting.delete()
- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(workout_id)))
-
-
class SetSmartReprTestCase(WgerTestCase):
"""Tests the "smart text representation" for sets"""
diff --git a/wger/manager/tests/test_workout_canonical.py b/wger/manager/tests/test_workout_canonical.py
deleted file mode 100644
index 76f9ff27b..000000000
--- a/wger/manager/tests/test_workout_canonical.py
+++ /dev/null
@@ -1,286 +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.cache import cache
-
-# wger
-from wger.core.models import DaysOfWeek
-from wger.core.tests.base_testcase import WgerTestCase
-from wger.exercises.models import (
- Exercise,
- Muscle,
-)
-from wger.manager.models import (
- Day,
- Set,
- Setting,
- Workout,
-)
-from wger.utils.cache import cache_mapper
-
-
-class WorkoutCanonicalFormTestCase(WgerTestCase):
- """
- Tests the canonical form for a workout
- """
- maxDiff = None
-
- def test_canonical_form(self):
- """
- Tests the canonical form for a workout
- """
-
- workout = Workout.objects.get(pk=1)
- setting_1 = Setting.objects.get(pk=1)
- setting_2 = Setting.objects.get(pk=2)
- muscle1 = Muscle.objects.get(pk=1)
- muscle2 = Muscle.objects.get(pk=2)
- setting1 = Setting.objects.get(pk=1)
- setting2 = Setting.objects.get(pk=2)
- image1 = '/media/exercise-images/1/protestschwein.jpg'
- image2 = '/media/exercise-images/1/wildschwein.jpg'
- self.assertEqual(
- workout.canonical_representation['muscles'], {
- 'back': [muscle2],
- 'frontsecondary': [muscle1],
- 'backsecondary': [muscle1],
- 'front': [muscle1]
- }
- )
- self.assertEqual(workout.canonical_representation['obj'], workout)
-
- canonical_form = {
- 'days_of_week': {
- 'day_list': [DaysOfWeek.objects.get(pk=2)],
- 'text': 'Tuesday'
- },
- 'muscles': {
- 'back': [muscle2],
- 'frontsecondary': [],
- 'backsecondary': [],
- 'front': [muscle1]
- },
- 'obj':
- Day.objects.get(pk=1),
- 'set_list': [
- {
- 'exercise_list': [
- {
- 'obj':
- Exercise.objects.get(pk=1),
- 'image_list': [
- {
- 'image': image1,
- 'is_main': True
- }, {
- 'image': image2,
- 'is_main': False
- }
- ],
- 'comment_list': ['test 123'],
- 'has_weight':
- False,
- 'setting_obj_list': [setting_1],
- 'setting_text':
- '2 \xd7 8 (3 RiR)',
- }
- ],
- 'is_superset':
- False,
- 'muscles': {
- 'back': [muscle2],
- 'frontsecondary': [],
- 'backsecondary': [],
- 'front': [muscle1]
- },
- 'obj':
- Set.objects.get(pk=1),
- 'settings_computed': [setting1] * 2
- }
- ]
- }
-
- days_test_data = workout.canonical_representation['day_list'][0]
- self.assertEqual(days_test_data['days_of_week'], canonical_form['days_of_week'])
- self.assertEqual(days_test_data['muscles'], canonical_form['muscles'])
- self.assertEqual(days_test_data['obj'], canonical_form['obj'])
-
- # Check that the content is the same
- for key in days_test_data['set_list'][0].keys():
- self.assertEqual(days_test_data['set_list'][0][key], canonical_form['set_list'][0][key])
-
- canonical_form = {
- 'days_of_week': {
- 'day_list': [DaysOfWeek.objects.get(pk=4)],
- 'text': 'Thursday'
- },
- 'obj':
- Day.objects.get(pk=2),
- 'muscles': {
- 'back': [muscle2],
- 'frontsecondary': [muscle1],
- 'backsecondary': [muscle1],
- 'front': []
- },
- 'set_list': [
- {
- 'exercise_list': [
- {
- 'obj': Exercise.objects.get(pk=2),
- 'image_list': [{
- 'image': image2,
- 'is_main': False
- }],
- 'comment_list': ['Foobar'],
- 'has_weight': True,
- 'setting_obj_list': [setting_2],
- 'setting_text': '4 \xd7 10 (15 kg)',
- }
- ],
- 'is_superset':
- False,
- 'muscles': {
- 'back': [muscle2],
- 'frontsecondary': [muscle1],
- 'backsecondary': [muscle1],
- 'front': []
- },
- 'obj':
- Set.objects.get(pk=2),
- 'settings_computed': [setting2] * 4
- }
- ]
- }
- days_test_data = workout.canonical_representation['day_list'][1]
- self.assertEqual(days_test_data['days_of_week'], canonical_form['days_of_week'])
- self.assertEqual(days_test_data['muscles'], canonical_form['muscles'])
- self.assertEqual(days_test_data['obj'], canonical_form['obj'])
-
- for key in days_test_data['set_list'][0].keys():
- self.assertEqual(days_test_data['set_list'][0][key], canonical_form['set_list'][0][key])
-
- # Check that the content is the same
- canonical_form = {
- 'days_of_week': {
- 'day_list': [DaysOfWeek.objects.get(pk=5)],
- 'text': 'Friday'
- },
- 'obj': Day.objects.get(pk=4),
- 'muscles': {
- 'back': [],
- 'front': [],
- 'frontsecondary': [],
- 'backsecondary': []
- },
- 'set_list': [],
- }
- self.assertEqual(workout.canonical_representation['day_list'][2], canonical_form)
-
- def test_canonical_form_day(self):
- """
- Tests the canonical form for a day
- """
-
- day = Day.objects.get(pk=5)
- weekday1 = DaysOfWeek.objects.get(pk=3)
- weekday2 = DaysOfWeek.objects.get(pk=5)
- muscle1 = Muscle.objects.get(pk=1)
- muscle2 = Muscle.objects.get(pk=2)
- setting = Setting.objects.get(pk=3)
- image2 = '/media/exercise-images/1/wildschwein.jpg'
- self.assertEqual(
- day.canonical_representation['days_of_week'], {
- 'day_list': [weekday1, weekday2],
- 'text': 'Wednesday, Friday'
- }
- )
- self.assertEqual(
- day.canonical_representation['muscles'], {
- 'back': [muscle2],
- 'frontsecondary': [muscle1],
- 'backsecondary': [muscle1],
- 'front': []
- }
- )
- self.assertEqual(day.canonical_representation['obj'], day)
-
- canonical_form = [
- {
- 'exercise_list': [
- {
- 'obj': Exercise.objects.get(pk=2),
- 'image_list': [{
- 'image': image2,
- 'is_main': False
- }],
- 'comment_list': ['Foobar'],
- 'has_weight': False,
- 'setting_obj_list': [Setting.objects.get(pk=3)],
- 'setting_text': '4 \xd7 10',
- }
- ],
- 'is_superset':
- False,
- 'muscles': {
- 'back': [muscle2],
- 'frontsecondary': [muscle1],
- 'backsecondary': [muscle1],
- 'front': []
- },
- 'obj':
- Set.objects.get(pk=3),
- 'settings_computed': [setting] * 4
- }
- ]
-
- self.assertEqual(day.canonical_representation['set_list'], canonical_form)
-
-
-class WorkoutCacheTestCase(WgerTestCase):
- """
- Test case for the workout canonical representation
- """
-
- def test_canonical_form_cache(self):
- """
- Tests that the workout cache of the canonical form is correctly generated
- """
- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(1)))
-
- workout = Workout.objects.get(pk=1)
- workout.canonical_representation
- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(1)))
-
- def test_canonical_form_cache_save(self):
- """
- Tests the workout cache when saving
- """
- workout = Workout.objects.get(pk=1)
- workout.canonical_representation
- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(1)))
-
- workout.save()
- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(1)))
-
- def test_canonical_form_cache_delete(self):
- """
- Tests the workout cache when deleting
- """
- workout = Workout.objects.get(pk=1)
- workout.canonical_representation
- self.assertTrue(cache.get(cache_mapper.get_workout_canonical(1)))
-
- workout.delete()
- self.assertFalse(cache.get(cache_mapper.get_workout_canonical(1)))
diff --git a/wger/manager/views/ical.py b/wger/manager/views/ical.py
index 94cdeb98c..a76289892 100644
--- a/wger/manager/views/ical.py
+++ b/wger/manager/views/ical.py
@@ -90,13 +90,13 @@ def get_events_workout(calendar, workout, duration, start_date=None):
generator = UIDGenerator()
site = Site.objects.get_current()
- for day in workout.canonical_representation['day_list']:
+ for day in workout.day_set.all():
# Make the description of the event with the day's exercises
description_list = []
- for set in day['set_list']:
- for exercise in set['exercise_list']:
- description_list.append(str(exercise['obj']))
+ for set_obj in day.set_set.all():
+ for exercise in set_obj.exercises:
+ description_list.append(str(exercise))
description = ', '.join(description_list) if description_list else day['obj'].description
# Make an event for each weekday
diff --git a/wger/manager/views/workout.py b/wger/manager/views/workout.py
index 31c52024b..a4b4ca655 100644
--- a/wger/manager/views/workout.py
+++ b/wger/manager/views/workout.py
@@ -108,7 +108,6 @@ def view(request, pk):
if not is_owner and not user.userprofile.ro_access:
return HttpResponseForbidden()
- canonical = workout.canonical_representation
uid, token = make_token(user)
template_data['workout'] = workout
diff --git a/wger/utils/cache.py b/wger/utils/cache.py
index 700fd7398..624a19e44 100644
--- a/wger/utils/cache.py
+++ b/wger/utils/cache.py
@@ -31,10 +31,6 @@ def delete_template_fragment_cache(fragment_name='', vary_on=None):
cache.delete(make_template_fragment_key(fragment_name, out))
-def reset_workout_canonical_form(workout_id):
- cache.delete(cache_mapper.get_workout_canonical(workout_id))
-
-
def reset_workout_log(user_pk, year, month, day=None):
"""
Resets the cached workout logs
@@ -56,7 +52,6 @@ class CacheKeyMapper(object):
LANGUAGE_CACHE_KEY = 'language-{0}'
LANGUAGE_CONFIG_CACHE_KEY = 'language-config-{0}-{1}'
INGREDIENT_CACHE_KEY = 'ingredient-{0}'
- WORKOUT_CANONICAL_REPRESENTATION = 'workout-canonical-representation-{0}'
WORKOUT_LOG_LIST = 'workout-log-hash-{0}'
NUTRITION_CACHE_KEY = 'nutrition-cache-log-{0}'
@@ -89,12 +84,6 @@ class CacheKeyMapper(object):
"""
return self.INGREDIENT_CACHE_KEY.format(self.get_pk(param))
- def get_workout_canonical(self, param):
- """
- Return the workout canonical representation
- """
- return self.WORKOUT_CANONICAL_REPRESENTATION.format(self.get_pk(param))
-
def get_workout_log_list(self, hash_value):
"""
Return the workout canonical representation