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 2 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
29 changes: 25 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,19 @@ 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}

print(workout_canonical_form)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better remove this :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should remove this debug line

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

Expand Down Expand Up @@ -426,6 +434,9 @@ 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 +451,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 +512,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 +529,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
8 changes: 8 additions & 0 deletions wger/manager/views/workout.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing am I'm not sure about is that if a workout has exercises that train a muscle as the main and the secondary muscle, the result is a bit fuzzy with the colors. I would suggest that we only colour the secondary muscles if there are no main ones, something like this:

if i not in muscles_front and i not in canonical['muscles']['front']:
    [...]

The same below

muscles_front.append('images/muscles/secondary/muscle-{0}.svg'.format(i))
for i in canonical['muscles']['backsecondary']:
if i not in 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