Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Cleanup PDF image and comment collector

Roland Geider9a47c7d60c7c
diff --git a/wger/manager/helpers.py b/wger/manager/helpers.py
index 641989222..3185a4d8d 100644
--- a/wger/manager/helpers.py
+++ b/wger/manager/helpers.py
@@ -36,7 +36,7 @@ from wger.utils.helpers import normalize_decimal
from wger.utils.pdf import styleSheet
-def render_workout_day(day, nr_of_weeks, comments=False):
+def render_workout_day(day, nr_of_weeks, images=False, comments=False):
'''
Render a table with reportlab with the contents of the training day
'''
@@ -87,26 +87,27 @@ def render_workout_day(day, nr_of_weeks, comments=False):
else:
setting_out = Paragraph(exercise['setting_text'], styleSheet["Small"])
- # Append a list of the exercise comments
- # if comments:
- if True:
+ # Collect a list of the exercise comments
+ item_list = [Paragraph('', styleSheet["Small"])]
+ if comments:
item_list = [ListItem(Paragraph(i, style=styleSheet["ExerciseComments"]))
for i in exercise['comment_list']]
- image = Paragraph('', styleSheet["Small"])
+ # Add the exercise's main image
+ image = Paragraph('', styleSheet["Small"])
+ if images:
if exercise['obj'].main_image:
image = Image(exercise['obj'].main_image.image)
image.drawHeight = 1.5 * cm * image.drawHeight / image.drawWidth
image.drawWidth = 1.5 * cm
- exercise_content = [Paragraph(exercise['obj'].name, styleSheet["Small"]),
- image,
- ListFlowable(item_list,
- bulletType='bullet',
- bulletFontSize=5,
- start='square')]
- # Only show the exercise name
- else:
- exercise_content = Paragraph(exercise['obj'].name, styleSheet["Small"])
+
+ # Put the name and images and comments together
+ exercise_content = [Paragraph(exercise['obj'].name, styleSheet["Small"]),
+ image,
+ ListFlowable(item_list,
+ bulletType='bullet',
+ bulletFontSize=5,
+ start='square')]
data.append([set_count,
exercise_content,
diff --git a/wger/manager/views/pdf.py b/wger/manager/views/pdf.py
index 78e30d90c..d8667e082 100644
--- a/wger/manager/views/pdf.py
+++ b/wger/manager/views/pdf.py
@@ -92,7 +92,7 @@ def workout_log(request, id, images=False, comments=False, uidb64=None, token=No
# Iterate through the Workout and render the training days
for day in workout.canonical_representation['day_list']:
- elements.append(render_workout_day(day, nr_of_weeks=7, comments=comments))
+ elements.append(render_workout_day(day, nr_of_weeks=7, images=images, comments=comments))
elements.append(Spacer(10 * cm, 0.5 * cm))
# Footer, date and info