Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Check that the last weight entry has actually a weight before dividing

Roland Geider67b82dade816
diff --git a/docs/changelog.rst b/docs/changelog.rst
index a6fab0b44..6a29afe34 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -29,11 +29,12 @@ Upgrade steps from 2.0:
+ /workout/
- ``comment`` was renamed to name
- field ``description`` was added, for longer descriptions
-* `#666`_, `#656`_ (thanks `@jackmulligan-ire`_),
+* `#666`_, `#656`_ (thanks `@jackmulligan-ire`_), `#716`_
.. _#572: https://github.com/wger-project/wger/issues/572
.. _#656: https://github.com/wger-project/wger/issues/656
.. _#666: https://github.com/wger-project/wger/issues/666
+.. _#716: https://github.com/wger-project/wger/issues/716
.. _@jackmulligan-ire: https://github.com/jackmulligan-ire
diff --git a/wger/nutrition/models/plan.py b/wger/nutrition/models/plan.py
index 6fbcf8d65..3ceb1b7be 100644
--- a/wger/nutrition/models/plan.py
+++ b/wger/nutrition/models/plan.py
@@ -147,7 +147,7 @@ class NutritionPlan(models.Model):
# Per body weight
weight_entry = self.get_closest_weight_entry()
- if weight_entry:
+ if weight_entry and weight_entry.weight:
for key in result['per_kg'].keys():
result['per_kg'][key] = result['total'][key] / weight_entry.weight