From b0ec10a5cdcc722a63b3395b7382240e91fd20de Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Wed, 5 May 2021 11:27:33 +0200 Subject: [PATCH] Rename workout model attributes 'comment' is renamed to 'name' and a new field 'description' is now available for actual longer descriptions if needed Closes #666 --- README.md | 1 + docs/changelog.rst | 13 +- wger/core/demo.py | 8 +- wger/core/templates/tags/render_day.html | 184 +++--- .../exercises/tests/test_exercise_comments.py | 2 +- wger/manager/api/views.py | 3 +- wger/manager/fixtures/test-workout-data.json | 15 +- wger/manager/forms.py | 13 +- .../migrations/0012_auto_20210430_1449.py | 41 ++ wger/manager/models.py | 22 +- wger/manager/templates/workout/log.html | 6 - wger/manager/templates/workout/view.html | 10 +- wger/manager/tests/test_copy_workout.py | 2 +- wger/manager/tests/test_workout.py | 6 +- wger/manager/views/pdf.py | 9 +- wger/manager/views/workout.py | 8 +- wger/nutrition/templates/plan/view.html | 525 ++++++++++-------- 17 files changed, 494 insertions(+), 374 deletions(-) create mode 100644 wger/manager/migrations/0012_auto_20210430_1449.py diff --git a/README.md b/README.md index 26ca75014..16a29fee6 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ For a live system, refer to the project's site: ![Workout plan](https://raw.githubusercontent.com/wger-project/wger/master/wger/software/static/images/workout.png) + ## Installation These are the basic steps to install and run the application locally on a Linux diff --git a/docs/changelog.rst b/docs/changelog.rst index 2dde0225c..d57d536cb 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -20,7 +20,16 @@ Upgrade steps from 2.0: 🧰 Maintenance: -* +* Changes to the REST API: + + /exerciseimage/ + - ``exercise`` was renamed to ``exercise_base`` (was pointing there anyway) + + /workout/ + - ``comment`` was renamed to name + - field ``description`` was added, for longer descriptions +* `#666`_, + +.. _#666: https://github.com/wger-project/wger/issues/666 + 2.0 @@ -108,7 +117,7 @@ Upgrade steps from 1.9: .. _@jeevikaghosh: https://github.com/jeevikaghosh .. _@bradsk88: https://github.com/bradsk88 .. _@Sidrah-Madiha: https://github.com/Sidrah-Madiha -.. _@calvinrw : https://github.com/calvinrw +.. _@calvinrw: https://github.com/calvinrw .. _#246: https://github.com/wger-project/wger/issues/246 diff --git a/wger/core/demo.py b/wger/core/demo.py index b0a4dacb2..46d345574 100644 --- a/wger/core/demo.py +++ b/wger/core/demo.py @@ -83,7 +83,7 @@ def create_demo_entries(user): # setting_list = [] weight_log = [] - workout = Workout(user=user, comment=_('Sample workout')) + workout = Workout(user=user, name=_('Sample workout')) workout.save() monday = DaysOfWeek.objects.get(pk=1) wednesday = DaysOfWeek.objects.get(pk=3) @@ -338,11 +338,11 @@ def create_demo_entries(user): # # create some empty workouts to fill the list - workout2 = Workout(user=user, comment=_('Placeholder workout nr {0} for schedule').format(1)) + workout2 = Workout(user=user, name=_('Placeholder workout nr {0} for schedule').format(1)) workout2.save() - workout3 = Workout(user=user, comment=_('Placeholder workout nr {0} for schedule').format(2)) + workout3 = Workout(user=user, name=_('Placeholder workout nr {0} for schedule').format(2)) workout3.save() - workout4 = Workout(user=user, comment=_('Placeholder workout nr {0} for schedule').format(3)) + workout4 = Workout(user=user, name=_('Placeholder workout nr {0} for schedule').format(3)) workout4.save() schedule = Schedule() diff --git a/wger/core/templates/tags/render_day.html b/wger/core/templates/tags/render_day.html index 6db06f8ee..dca3fad4e 100644 --- a/wger/core/templates/tags/render_day.html +++ b/wger/core/templates/tags/render_day.html @@ -1,69 +1,83 @@ {% load i18n static wger_extras thumbnail %} - - +
+ - {% for set in day.set_list %} + {% for set in day.set_list %} - - {% endfor %} - {% if editable %} + {% endfor %} + {% if editable %} - {% endif %} + {% endif %} -
- {{ day.days_of_week.text }} – {{ day.obj.description }} + {% if editable %} -
+ #{{ forloop.counter }} {% if editable %}
{% for exercise in set.exercise_list %} -
-
+
+
- - -
-

- {{ exercise.obj.name }} -

-

{{exercise.setting_text}}

- - {% if editable %} - {% if not exercise.setting_obj_list %} -

- {% translate "This exercise has no repetitions." %}
- - {% translate "Edit them now."%} +

- {% if exercise.comment_list %} -

- {% for comment in exercise.comment_list %} - {{comment}}
- {% endfor %} -

- {% endif %} - {% endif %} +
+

+ {{ exercise.obj.name }} +

+

{{ exercise.setting_text }}

+ + {% if editable %} + {% if not exercise.setting_obj_list %} +

+ {% translate "This exercise has no repetitions." %}
+ + {% translate "Edit them now." %} + +

+ {% endif %} + + {% if exercise.comment_list %} +

+ {% for comment in exercise.comment_list %} + {{ comment }}
+ {% endfor %} +

+ {% endif %} + {% endif %} +
-
{% endfor %}
{% translate "Add exercises to this workout day" %}
diff --git a/wger/exercises/tests/test_exercise_comments.py b/wger/exercises/tests/test_exercise_comments.py index 9009da56b..85330a5bc 100644 --- a/wger/exercises/tests/test_exercise_comments.py +++ b/wger/exercises/tests/test_exercise_comments.py @@ -77,7 +77,7 @@ class ExercisecommentsTestCase(WgerTestCase): # Comments are loaded comments = exercise_1.exercisecomment_set.all() - comment_1 = comments[0] + comment_1: ExerciseComment = comments[0] self.assertEqual(comment_1.id, 1) self.assertEqual(comment_1.comment, "test 123") self.assertEqual(len(comments), 1) diff --git a/wger/manager/api/views.py b/wger/manager/api/views.py index 360405dbb..7920dd41a 100644 --- a/wger/manager/api/views.py +++ b/wger/manager/api/views.py @@ -61,7 +61,8 @@ class WorkoutViewSet(viewsets.ModelViewSet): serializer_class = WorkoutSerializer is_private = True ordering_fields = '__all__' - filterset_fields = ('comment', + filterset_fields = ('name', + 'description', 'creation_date') def get_queryset(self): diff --git a/wger/manager/fixtures/test-workout-data.json b/wger/manager/fixtures/test-workout-data.json index 6c1b53cde..0678267ec 100644 --- a/wger/manager/fixtures/test-workout-data.json +++ b/wger/manager/fixtures/test-workout-data.json @@ -3,27 +3,30 @@ "pk": 1, "model": "manager.workout", "fields": { - "comment": "A test workout", + "name": "A test workout", "user": 1, - "creation_date": "2012-11-01" + "creation_date": "2012-11-01", + "description": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna" } }, { "pk": 2, "model": "manager.workout", "fields": { - "comment": "Another test workout", + "name": "Another test workout", "user": 1, - "creation_date": "2012-11-10" + "creation_date": "2012-11-10", + "description": "The wild boar (Sus scrofa), also known as the \"wild swine\", \"common wild pig\", or simply \"wild pig\", is a suid native to much of Eurasia and North Africa" } }, { "pk": 3, "model": "manager.workout", "fields": { - "comment": "My test workout", + "name": "My test workout", "user": 2, - "creation_date": "2012-11-20" + "creation_date": "2012-11-20", + "description": "" } }, diff --git a/wger/manager/forms.py b/wger/manager/forms.py index ac205c9b3..7af156eb6 100644 --- a/wger/manager/forms.py +++ b/wger/manager/forms.py @@ -73,9 +73,14 @@ class WorkoutForm(ModelForm): class WorkoutCopyForm(Form): - comment = CharField(max_length=100, - help_text=_('The goal or description of the new workout.'), - required=False) + name = CharField(max_length=100, + help_text=_('The name of the workout'), + required=False) + description = CharField(max_length=1000, + help_text=_("A short description or goal of the workout. For " + "example 'Focus on back' or 'Week 1 of program xy'."), + widget=widgets.Textarea, + required=False) class DayForm(ModelForm): @@ -111,7 +116,7 @@ class SetForm(ModelForm): class SettingForm(ModelForm): class Meta: model = Setting - exclude = ('set', 'exercise', 'order', 'comment') + exclude = ('set', 'exercise', 'order', 'name') class WorkoutLogForm(ModelForm): diff --git a/wger/manager/migrations/0012_auto_20210430_1449.py b/wger/manager/migrations/0012_auto_20210430_1449.py new file mode 100644 index 000000000..5b1b0a3f0 --- /dev/null +++ b/wger/manager/migrations/0012_auto_20210430_1449.py @@ -0,0 +1,41 @@ +# Generated by Django 3.1.8 on 2021-04-30 12:49 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('manager', '0011_remove_set_exercises'), + ] + + operations = [ + migrations.RenameField( + model_name='workout', + old_name='comment', + new_name='name' + ), + migrations.AddField( + model_name='workout', + name='description', + field=models.TextField(blank=True, + help_text="A short description or goal of the workout. For " + "example 'Focus on back' or 'Week 1 of program xy'.", + max_length=1000, verbose_name='Description'), + ), + migrations.AlterField( + model_name='workout', + name='name', + field=models.CharField(blank=True, + help_text='The name of the workout', + max_length=100, + verbose_name='Name'), + ), + migrations.AlterField( + model_name='setting', + name='reps', + field=models.IntegerField(validators=[django.core.validators.MinValueValidator(0), + django.core.validators.MaxValueValidator(600)], + verbose_name='Reps'), + ), + ] diff --git a/wger/manager/models.py b/wger/manager/models.py index 6148130b6..698371c82 100644 --- a/wger/manager/models.py +++ b/wger/manager/models.py @@ -80,11 +80,17 @@ class Workout(models.Model): ordering = ["-creation_date", ] creation_date = models.DateField(_('Creation date'), auto_now_add=True) - comment = models.CharField(verbose_name=_('Description'), - max_length=100, - blank=True, - help_text=_("A short description or goal of the workout. For " - "example 'Focus on back' or 'Week 1 of program xy'.")) + name = models.CharField(verbose_name=_('Name'), + max_length=100, + blank=True, + help_text=_("The name of the workout")) + description = models.TextField(verbose_name=_('Description'), + max_length=1000, + blank=True, + help_text=_("A short description or goal of the workout. For " + "example 'Focus on back' or 'Week 1 of program " + "xy'.")) + user = models.ForeignKey(User, verbose_name=_('User'), on_delete=models.CASCADE) def get_absolute_url(self): @@ -97,8 +103,8 @@ class Workout(models.Model): """ Return a more human-readable representation """ - if self.comment: - return "{0}".format(self.comment) + if self.name: + return self.name else: return "{0} ({1})".format(_('Workout'), self.creation_date) @@ -361,7 +367,7 @@ class ScheduleStep(models.Model): """ Return a more human-readable representation """ - return self.workout.comment + return self.workout.name def get_dates(self): """ diff --git a/wger/manager/templates/workout/log.html b/wger/manager/templates/workout/log.html index f84935e07..7cf08a025 100644 --- a/wger/manager/templates/workout/log.html +++ b/wger/manager/templates/workout/log.html @@ -40,12 +40,6 @@ {# Content #} {# #} {% block content %} -{% if workout.comment %} -

- {% translate "Goal" %}: {{workout.comment}} -

-{% endif %} - {% for day in workout.canonical_representation.day_list %}

{{ day.obj.description }}

diff --git a/wger/manager/templates/workout/view.html b/wger/manager/templates/workout/view.html index 905c1f445..a750a9c7f 100644 --- a/wger/manager/templates/workout/view.html +++ b/wger/manager/templates/workout/view.html @@ -16,7 +16,7 @@ {# #} {# Title #} {# #} -{% block title %}{% translate "Workout" %} – {{ workout.creation_date }}{% endblock %} +{% block title %}{% translate "Workout" %}{% endblock %} {# #} @@ -52,8 +52,12 @@ $(document).ready(function () { {% block content %} -{% if workout.comment %} -

{{workout.comment}}

+{% if workout.name %} +

{{workout.name }}

+{% endif %} + +{% if workout.description %} +

{{ workout.description }}

{% endif %} {% for day in workout.canonical_representation.day_list %} diff --git a/wger/manager/tests/test_copy_workout.py b/wger/manager/tests/test_copy_workout.py index f1a55550f..da34ecfd2 100644 --- a/wger/manager/tests/test_copy_workout.py +++ b/wger/manager/tests/test_copy_workout.py @@ -47,7 +47,7 @@ class CopyWorkoutTestCase(WgerTestCase): # Copy the workout count_before = Workout.objects.count() self.client.post(reverse('manager:workout:copy', kwargs={'pk': '3'}), - {'comment': 'A copied workout'}) + {'name': 'A copied workout'}) count_after = Workout.objects.count() if not owner: diff --git a/wger/manager/tests/test_workout.py b/wger/manager/tests/test_workout.py index 217cac9c8..6fbcf7780 100644 --- a/wger/manager/tests/test_workout.py +++ b/wger/manager/tests/test_workout.py @@ -150,7 +150,7 @@ class EditWorkoutTestCase(WgerEditTestCase): pk = 3 user_success = 'test' user_fail = 'admin' - data = {'comment': 'A new comment'} + data = {'name': 'A new comment'} class WorkoutOverviewTestCase(WgerTestCase): @@ -192,7 +192,7 @@ class WorkoutModelTestCase(WgerTestCase): self.assertEqual('{0}'.format(workout), '{0} ({1})'.format('Workout', datetime.date.today())) - workout.comment = 'my description' + workout.name = 'my description' self.assertEqual('{0}'.format(workout), 'my description') @@ -204,4 +204,4 @@ class WorkoutApiTestCase(api_base_test.ApiBaseResourceTestCase): resource = Workout private_resource = True special_endpoints = ('canonical_representation',) - data = {'comment': 'A new comment'} + data = {'name': 'A new comment'} diff --git a/wger/manager/views/pdf.py b/wger/manager/views/pdf.py index 735868244..2e6b59161 100644 --- a/wger/manager/views/pdf.py +++ b/wger/manager/views/pdf.py @@ -93,11 +93,14 @@ def workout_log(request, id, images=False, comments=False, uidb64=None, token=No elements.append(Spacer(10 * cm, 0.5 * cm)) # Set the title - p = Paragraph('%(description)s' % - {'description': workout}, + p = Paragraph(f'{workout.name}', styleSheet["HeaderBold"]) elements.append(p) - elements.append(Spacer(10 * cm, 1.5 * cm)) + elements.append(Spacer(10 * cm, 0.5 * cm)) + if workout.description: + p = Paragraph(f'{workout.description}') + elements.append(p) + elements.append(Spacer(10 * cm, 1.5 * cm)) # Iterate through the Workout and render the training days for day in workout.canonical_representation['day_list']: diff --git a/wger/manager/views/workout.py b/wger/manager/views/workout.py index fa8830090..3c8ea9de6 100644 --- a/wger/manager/views/workout.py +++ b/wger/manager/views/workout.py @@ -146,7 +146,7 @@ def copy_workout(request, pk): workout_copy = copy.copy(workout) workout_copy.pk = None - workout_copy.comment = workout_form.cleaned_data['comment'] + workout_copy.name = workout_form.cleaned_data['name'] workout_copy.user = request.user workout_copy.save() @@ -180,7 +180,7 @@ def copy_workout(request, pk): return HttpResponseRedirect(reverse('manager:workout:view', kwargs={'pk': workout_copy.id})) else: - workout_form = WorkoutCopyForm({'comment': workout.comment}) + workout_form = WorkoutCopyForm({'name': workout.name, 'description': workout.description}) workout_form.helper = FormHelper() workout_form.helper.form_id = slugify(request.path) workout_form.helper.form_method = 'post' @@ -193,7 +193,7 @@ def copy_workout(request, pk): template_data.update(csrf(request)) template_data['title'] = _('Copy workout') template_data['form'] = workout_form - template_data['form_fields'] = [workout_form['comment']] + template_data['form_fields'] = [workout_form['name']] template_data['submit_text'] = _('Copy') return render(request, 'form.html', template_data) @@ -217,7 +217,7 @@ class WorkoutDeleteView(WgerDeleteMixin, LoginRequiredMixin, DeleteView): """ model = Workout - fields = ('comment',) + fields = ('name',) success_url = reverse_lazy('manager:workout:overview') messages = gettext_lazy('Successfully deleted') diff --git a/wger/nutrition/templates/plan/view.html b/wger/nutrition/templates/plan/view.html index 9fa511776..2ccf4f087 100644 --- a/wger/nutrition/templates/plan/view.html +++ b/wger/nutrition/templates/plan/view.html @@ -9,31 +9,30 @@ {% block opengraph %} {{ block.super }} - + {% endblock %} {# #} {# Title #} {# #} -{% block title %}{% translate "Nutrition plan" %} – {{ plan.creation_date}}{% endblock %} +{% block title %}{% translate "Nutrition plan" %}{% endblock %} {# #} {# Header #} {# #} {% block header %} - + function wgerCustomModalInit() { + // Init the autocompleter after loading the modal dialog + wgerInitIngredientAutocompleter(); + } + {% endblock %} @@ -42,160 +41,188 @@ function wgerCustomModalInit() {# Content #} {# #} {% block content %} -{% if plan.description %} -

{{plan.description}}

-{% endif %} + {% if plan.description %} +

{{ plan.description }}

+ {% endif %} -
- - - - - - - - - - - - - - - - - - - - {% for meal in plan.meal_set.select_related %} - - - - - - - - - {% empty %} - {% if is_owner %} - - - + +

{% translate "Nutritional data" %}

+ {% if weight_entry %} +
+ {% blocktranslate with date=weight_entry.date weight=weight_entry.weight trimmed %} + Based on the weight entry dated {{ date }} ({{ weight }}) + {% endblocktranslate %} +
{% endif %} - {% endfor %} - {% if is_owner %} - - - - - - - {% endif %} - -
{% translate "Meal" %}{% translate "Contents" %}{% translate "Energy" %}{% translate "Protein" %}{% translate "Carbohydrates" %}{% translate "Fat" %}
{% translate 'kcal' %} / {% translate 'kJ' %}{% trans_weight_unit 'g' owner_user %}{% trans_weight_unit 'g' owner_user %}{% trans_weight_unit 'g' owner_user %}
- - {% translate "Nr."%} {{ forloop.counter }} - {% if meal.time %} – {{meal.time|time:"H:i"}}{% endif %} - +
+ + + + + + + + + + + + + + + + + + + {% for meal in plan.meal_set.select_related %} + + - {% for item in meal.mealitem_set.select_related %} - + + + {% for item in meal.mealitem_set.select_related %} + + + + + + + {% empty %} + {% if is_owner %} + + {% endif %} + {% endfor %} + + + + + + + + + + {% empty %} {% if is_owner %} - - - - + + + {% endif %} - - - - - - - {% empty %} + {% endfor %} {% if is_owner %} - + + + + + + {% endif %} - {% endfor %} + +
{% translate "Contents" %}{% translate "Energy" %}{% translate "Protein" %}{% translate "Carbohydrates" %}{% translate "Fat" %}
{% translate 'kcal' %} / {% translate 'kJ' %}{% trans_weight_unit 'g' owner_user %}{% trans_weight_unit 'g' owner_user %}{% trans_weight_unit 'g' owner_user %}
+ {% if is_owner %} + + {% endif %} - {% if is_owner %} - - {% endif %} - - {% if item.get_unit_type == MEALITEM_WEIGHT_GRAM %}{{ item.amount|floatformat:"0" }}g - {% else %} - {{ item.amount|floatformat:"0" }} × {{ item.weight_unit.unit.name }} - {% endif %} - {{ item.ingredient.name }} +

{% if meal.time %}{{ meal.time|time:"H:i" }}{% endif %}

+
+ {% if item.get_unit_type == MEALITEM_WEIGHT_GRAM %} + {{ item.amount|floatformat:"0" }}g + {% else %} + {{ item.amount|floatformat:"0" }} × {{ item.weight_unit.unit.name }} + {% endif %} + {{ item.ingredient.name }} + + {% if is_owner %} + + + {% endif %} + {{ item.get_nutritional_values.energy|floatformat:1 }} + / + {{ item.get_nutritional_values.energy_kilojoule|floatformat:1 }}{{ item.get_nutritional_values.protein|floatformat:1 }}{{ item.get_nutritional_values.carbohydrates|floatformat:1 }}{{ item.get_nutritional_values.fat|floatformat:1 }}
+ + {% translate "No items for this meal." %} + {% translate "Add one now." %} + +
Σ + + {{ meal.get_nutritional_values.energy|floatformat:1 }} / + {{ meal.get_nutritional_values.energy_kilojoule|floatformat:1 }} + + + + {{ meal.get_nutritional_values.protein|floatformat:1 }} + + + + {{ meal.get_nutritional_values.carbohydrates|floatformat:1 }} + + + + {{ meal.get_nutritional_values.fat|floatformat:1 }} + +
+ + {% translate "No meals for this plan." %} + {% translate "Add one now." %} + +
{{item.get_nutritional_values.energy|floatformat:1}} / - {{item.get_nutritional_values.energy_kilojoule|floatformat:1}}{{item.get_nutritional_values.protein|floatformat:1}}{{item.get_nutritional_values.carbohydrates|floatformat:1}}{{item.get_nutritional_values.fat|floatformat:1}}
- - {% translate "No items for this meal." %} - {% translate "Add one now."%} - -
+ {% translate "Log this Plan" %}
+ + {% translate "Add a new meal" %} + +
+
-
{{meal.get_nutritional_values.energy|floatformat:1}} / - {{meal.get_nutritional_values.energy_kilojoule|floatformat:1}}{{meal.get_nutritional_values.protein|floatformat:1}}{{meal.get_nutritional_values.carbohydrates|floatformat:1}}{{meal.get_nutritional_values.fat|floatformat:1}}
- - {% translate "No meals for this plan." %} - {% translate "Add one now." %} - -
- {% translate "Log this Plan" %}
- - {% translate "Add a new meal" %} - -
-
- - -

{% translate "Nutritional data" %}

-{% if weight_entry %} -
- {% blocktranslate with date=weight_entry.date weight=weight_entry.weight trimmed %} - Based on the weight entry dated {{date}} ({{weight}}) - {% endblocktranslate %} -
-{% endif %} - - +
+ @@ -208,42 +235,44 @@ function wgerCustomModalInit() {% endif %} - - + + - + - - - + + + - - - + + + - + - - - + + + - + @@ -254,32 +283,33 @@ function wgerCustomModalInit() - + - + - -
{% translate "Macronutrients" %} {% translate "Total" %}
{% translate "Energy" %}{{nutritional_data.total.energy|floatformat:0}} {% translate "kcal" %} / - {{nutritional_data.total.energy_kilojoule|floatformat:0}} {% translate "kJ" %}{{ nutritional_data.total.energy|floatformat:0 }} {% translate "kcal" %} + / + {{ nutritional_data.total.energy_kilojoule|floatformat:0 }} {% translate "kJ" %}
{% translate "Protein" %}{{nutritional_data.total.protein|floatformat:1}} {% trans_weight_unit 'g' owner_user %}{{nutritional_data.percent.protein|floatformat:1}} %{{nutritional_data.per_kg.protein|floatformat:2}}{{ nutritional_data.total.protein|floatformat:1 }} {% trans_weight_unit 'g' owner_user %}{{ nutritional_data.percent.protein|floatformat:1 }} %{{ nutritional_data.per_kg.protein|floatformat:2 }}
{% translate "Carbohydrates" %}{{nutritional_data.total.carbohydrates|floatformat:1}} {% trans_weight_unit 'g' owner_user %}{{nutritional_data.percent.carbohydrates|floatformat:1}} %{{nutritional_data.per_kg.carbohydrates|floatformat:2}}{{ nutritional_data.total.carbohydrates|floatformat:1 }} {% trans_weight_unit 'g' owner_user %}{{ nutritional_data.percent.carbohydrates|floatformat:1 }} % + {{ nutritional_data.per_kg.carbohydrates|floatformat:2 }}
{% translate "Sugar content in carbohydrates" %}{{nutritional_data.total.carbohydrates_sugar|floatformat:1}} {% trans_weight_unit 'g' owner_user %}{{ nutritional_data.total.carbohydrates_sugar|floatformat:1 }} {% trans_weight_unit 'g' owner_user %}
{% translate "Fat" %}{{nutritional_data.total.fat|floatformat:1}} {% trans_weight_unit 'g' owner_user %}{{nutritional_data.percent.fat|floatformat:1}} %{{nutritional_data.per_kg.fat|floatformat:2}}{{ nutritional_data.total.fat|floatformat:1 }} {% trans_weight_unit 'g' owner_user %}{{ nutritional_data.percent.fat|floatformat:1 }} %{{ nutritional_data.per_kg.fat|floatformat:2 }}
{% translate "Saturated fat content in fats" %}{{nutritional_data.total.fat_saturated|floatformat:1}} {% trans_weight_unit 'g' owner_user %}{{ nutritional_data.total.fat_saturated|floatformat:1 }} {% trans_weight_unit 'g' owner_user %}
{% translate "Fibres" %}{{nutritional_data.total.fibres|floatformat}} {% trans_weight_unit 'g' owner_user %}{{ nutritional_data.total.fibres|floatformat }} {% trans_weight_unit 'g' owner_user %}
{% translate "Sodium" %}{{nutritional_data.total.sodium|floatformat}} {% trans_weight_unit 'g' owner_user %}{{ nutritional_data.total.sodium|floatformat }} {% trans_weight_unit 'g' owner_user %}
+ + -

{% translate "Nutrition diary" %} - {{nutritional_data.total.energy|floatformat:0}}{% translate "kcal" %}

-
+

{% translate "Nutrition diary" %} - + {{ nutritional_data.total.energy|floatformat:0 }}{% translate "kcal" %}

+
- - +
+ - - + + {% for entry in log_data %} {% empty %} - + @@ -304,18 +334,20 @@ function wgerCustomModalInit() {% if log_data %} {% endif %} - -
{% translate "Date" %} {% translate "Logged" %} {% translate "Difference" %}
@@ -295,7 +325,7 @@ function wgerCustomModalInit()
{% translate "nothing found" %}
- {% translate "View complete nutrition log" %} + {% translate "View complete nutrition log" %}
+ + -{% if is_owner %} -

- {% translate "Add custom diary entry" %} -

-{% endif %} + {% if is_owner %} +

+ {% translate "Add custom diary entry" %} +

+ {% endif %} {% endblock %} @@ -323,42 +355,45 @@ function wgerCustomModalInit() {# Side bar #} {# #} {% block sidebar %} -

{% translate "Energy" %}

- - +

{% translate "Energy" %}

+
+ - + - - + + {% if is_owner and owner_user.userprofile.calories and plan.has_goal_calories %} - {% with total=plan.get_calories_approximation %} - - - - - {% endwith %} + {% with total=plan.get_calories_approximation %} + + + + + {% endwith %} {% endif %} - -
{% translate "Energy" %}{{nutritional_data.total.energy|floatformat:0}} {% translate "kcal" %}{{ nutritional_data.total.energy|floatformat:0 }} {% translate "kcal" %}
{% translate "Goal" %} - {{owner_user.userprofile.calories}} {% translate "kcal" %}
{% translate "Goal" %} + {{ owner_user.userprofile.calories }} {% translate "kcal" %} +
+ + -{% if is_owner and plan.has_goal_calories %} -

{% blocktranslate %}You have selected that this nutritional plan has a - goal amount of calories. Use the calculator or enter the value yourself.{% endblocktranslate %} - {% translate "That's done here" %} -

-{% endif %} + {% if is_owner and plan.has_goal_calories %} +

{% blocktranslate %}You have selected that this nutritional plan has a + goal amount of calories. Use the calculator or enter the value + yourself.{% endblocktranslate %} + {% translate "That's done here" %} +

+ {% endif %} -{% if language.short_name != 'en' and is_owner %} -

- {% translate "If you find the ingredient list too short, you might want to activate the preference to also show English ingredients." %} - {% translate "That's done here" %}. -

-{% endif %} + {% if language.short_name != 'en' and is_owner %} +

+ {% translate "If you find the ingredient list too short, you might want to activate the preference to also show English ingredients." %} + {% translate "That's done here" %}. +

+ {% endif %} {% endblock %} @@ -367,31 +402,35 @@ function wgerCustomModalInit() {# Options #} {# #} {% block options %} -