Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fedora instruction + secondary muscle #282

Merged
merged 5 commits into from
May 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ and stable state.
$ virtualenv --python python3 venv-django
$ source venv-django/bin/activate

On fedora 23 ::

$ sudo dnf install python3-devel python-virtualenv nodejs npm libjpeg-turbo-devel zlib-devel git
$ virtualenv --python python3 venv-django
$ source venv-django/bin/activate


2) Start the application. This will download the required JS and CSS libraries
and create a SQlite database and populate it with data on the first run.

Expand Down
30 changes: 26 additions & 4 deletions wger/manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def canonical_representation(self):
day_canonical_repr = []
muscles_front = []
muscles_back = []
muscles_front_secondary = []
muscles_back_secondary = []

# Sort list by weekday
day_list = [i for i in self.day_set.select_related()]
Expand All @@ -132,13 +134,21 @@ def canonical_representation(self):
for i in canonical_repr_day['muscles']['back']:
if i not in muscles_back:
muscles_back.append(i)
for i in canonical_repr_day['muscles']['frontsecondary']:
if i not in muscles_front_secondary:
muscles_front_secondary.append(i)
for i in canonical_repr_day['muscles']['backsecondary']:
if i not in muscles_back_secondary:
muscles_back_secondary.append(i)

day_canonical_repr.append(canonical_repr_day)

workout_canonical_form = {'obj': self,
'muscles': {'front': muscles_front, 'back': muscles_back},
'muscles': {'front': muscles_front,
'back': muscles_back,
'frontsecondary': muscles_front_secondary,
'backsecondary': muscles_back_secondary},
'day_list': day_canonical_repr}

# Save to cache
cache.set(cache_mapper.get_workout_canonical(self.pk), workout_canonical_form)

Expand Down Expand Up @@ -426,6 +436,8 @@ def get_canonical_representation(self):
canonical_repr = []
muscles_front = []
muscles_back = []
muscles_front_secondary = []
muscles_back_secondary = []

for set_obj in self.set_set.select_related():
exercise_tmp = []
Expand All @@ -440,6 +452,12 @@ def get_canonical_representation(self):
elif not muscle.is_front and muscle.id not in muscles_back:
muscles_back.append(muscle.id)

for muscle in exercise.muscles_secondary.all():
if muscle.is_front and muscle.id not in muscles_front:
muscles_front_secondary.append(muscle.id)
elif not muscle.is_front and muscle.id not in muscles_back:
muscles_back_secondary.append(muscle.id)

for setting in Setting.objects.filter(set=set_obj,
exercise=exercise).order_by('order', 'id'):
setting_tmp.append(setting)
Expand Down Expand Up @@ -495,7 +513,9 @@ def get_canonical_representation(self):
'has_settings': has_setting_tmp,
'muscles': {
'back': muscles_back,
'front': muscles_front
'front': muscles_front,
'frontsecondary': muscles_front_secondary,
'backsecondary': muscles_front_secondary
}})

# Days of the week
Expand All @@ -510,7 +530,9 @@ def get_canonical_representation(self):
'day_list': tmp_days_of_week},
'muscles': {
'back': muscles_back,
'front': muscles_front
'front': muscles_front,
'frontsecondary': muscles_front_secondary,
'backsecondary': muscles_front_secondary
},
'set_list': canonical_repr}

Expand Down
29 changes: 21 additions & 8 deletions wger/manager/tests/test_workout_canonical.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ def test_canonical_form(self):
workout = Workout.objects.get(pk=1)
setting_1 = Setting.objects.get(pk=1)
setting_2 = Setting.objects.get(pk=2)
self.assertEqual(workout.canonical_representation['muscles'], {'back': [2], 'front': [1]})
self.assertEqual(workout.canonical_representation['muscles'],
{'back': [2], 'frontsecondary': [1], 'backsecondary': [1], 'front': [1]})
self.assertEqual(workout.canonical_representation['obj'], workout)

canonical_form = {'days_of_week': {'day_list': [DaysOfWeek.objects.get(pk=2)],
'text': u'Tuesday'},
'muscles': {'back': [2], 'front': [1]},
'muscles': {'back': [2],
'frontsecondary': [],
'backsecondary': [],
'front': [1]},
'obj': Day.objects.get(pk=1),
'set_list': [{'exercise_list': [{'obj': Exercise.objects.get(pk=1),
'comment_list': [u'test 123'],
Expand All @@ -58,14 +62,18 @@ def test_canonical_form(self):
'setting_text': u'2 \xd7 8'}],
'is_superset': False,
'has_settings': True,
'muscles': {'back': [2], 'front': [1]},
'muscles': {'back': [2], 'frontsecondary': [],
'backsecondary': [],
'front': [1]},
'obj': Set.objects.get(pk=1)}]}
self.assertEqual(workout.canonical_representation['day_list'][0], canonical_form)

canonical_form = {'days_of_week': {'day_list': [DaysOfWeek.objects.get(pk=4)],
'text': u'Thursday'},
'obj': Day.objects.get(pk=2),
'muscles': {'back': [2], 'front': []},
'muscles': {'back': [2],
'frontsecondary': [1], 'backsecondary': [1],
'front': []},
'set_list': [{'exercise_list': [{'obj': Exercise.objects.get(pk=2),
'comment_list': [u'Foobar'],
'has_weight': True,
Expand All @@ -79,14 +87,17 @@ def test_canonical_form(self):
'setting_text': u'4 \xd7 10 (15kg)'}],
'is_superset': False,
'has_settings': True,
'muscles': {'back': [2], 'front': []},
'muscles': {'back': [2],
'frontsecondary': [1], 'backsecondary': [1],
'front': []},
'obj': Set.objects.get(pk=2)}]}
self.assertEqual(workout.canonical_representation['day_list'][1], canonical_form)

canonical_form = {'days_of_week': {'day_list': [DaysOfWeek.objects.get(pk=5)],
'text': u'Friday'},
'obj': Day.objects.get(pk=4),
'muscles': {'back': [], 'front': []},
'muscles': {'back': [], 'front': [],
'frontsecondary': [], 'backsecondary': []},
'set_list': []}
self.assertEqual(workout.canonical_representation['day_list'][2], canonical_form)

Expand All @@ -100,7 +111,8 @@ def test_canonical_form_day(self):
weekday2 = DaysOfWeek.objects.get(pk=5)
self.assertEqual(day.canonical_representation['days_of_week'],
{'day_list': [weekday1, weekday2], 'text': u'Wednesday, Friday'})
self.assertEqual(day.canonical_representation['muscles'], {'back': [2], 'front': []})
self.assertEqual(day.canonical_representation['muscles'],
{'back': [2], 'frontsecondary': [1], 'backsecondary': [1], 'front': []})
self.assertEqual(day.canonical_representation['obj'], day)

canonical_form = [{'exercise_list': [{'obj': Exercise.objects.get(pk=2),
Expand All @@ -113,7 +125,8 @@ def test_canonical_form_day(self):
'setting_text': u'4 \xd7 10'}],
'is_superset': False,
'has_settings': True,
'muscles': {'back': [2], 'front': []},
'muscles': {'back': [2], 'frontsecondary': [1],
'backsecondary': [1], 'front': []},
'obj': Set.objects.get(pk=3)}]

self.assertEqual(day.canonical_representation['set_list'], canonical_form)
Expand Down
7 changes: 7 additions & 0 deletions wger/manager/views/workout.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ def view(request, pk):
if i not in muscles_back:
muscles_back.append('images/muscles/main/muscle-{0}.svg'.format(i))

for i in canonical['muscles']['frontsecondary']:
if i not in muscles_front and i not in canonical['muscles']['front']:
muscles_front.append('images/muscles/secondary/muscle-{0}.svg'.format(i))
for i in canonical['muscles']['backsecondary']:
if i not in muscles_back and i not in canonical['muscles']['back']:
muscles_back.append('images/muscles/secondary/muscle-{0}.svg'.format(i))

# Append the silhouette of the human body as the last entry so the browser
# renders it in the background
muscles_front.append('images/muscles/muscular_system_front.svg')
Expand Down