Self hosted FLOSS fitness/workout, nutrition and weight tracker
changed ingredient.py to include kilojoule conversion of kcal. Changed calculator to reflect change on front end.
dereklia4c8971c2e5e
diff --git a/wger/nutrition/models.py b/wger/nutrition/models.pyindex bc17d0b92..242319529 100644--- a/wger/nutrition/models.py+++ b/wger/nutrition/models.py@@ -512,6 +512,11 @@ class Ingredient(AbstractSubmissionModel, AbstractLicenseModel, models.Model):"""return False+ def _get_energy_kilojoule(self):+ return self.energy * 4184++ energy_kilojoule = property(_get_energy_kilojoule)+class WeightUnit(models.Model):"""diff --git a/wger/nutrition/static/js/nutrition.js b/wger/nutrition/static/js/nutrition.jsindex 29a11e33e..ea6da7475 100644--- a/wger/nutrition/static/js/nutrition.js+++ b/wger/nutrition/static/js/nutrition.js@@ -33,6 +33,7 @@ function updateIngredientValue(url) {// Replace the nutritional values$('#value-energy').html(parseFloat(data.energy).toFixed(2));+ $('#value-energy-kjoule').html(parseFloat(data.energy * 4184).toFixed(2));$('#value-protein').html(parseFloat(data.protein).toFixed(2));$('#value-carbohydrates').html(parseFloat(data.carbohydrates).toFixed(2));$('#value-carbohydrates-sugar').html(parseFloat(data.carbohydrates_sugar).toFixed(2));diff --git a/wger/nutrition/templates/ingredient/view.html b/wger/nutrition/templates/ingredient/view.htmlindex add62108a..39e58afdd 100644--- a/wger/nutrition/templates/ingredient/view.html+++ b/wger/nutrition/templates/ingredient/view.html@@ -76,7 +76,8 @@ the search.{% endblocktrans %}<tr><td>{% trans "Energy" %}</td><td itemprop="calories" class="text-right">- <span id="value-energy">{{ingredient.energy|floatformat:1}}</span> {% trans "kcal" %}+ <span id="value-energy">{{ingredient.energy|floatformat:1}}</span> {% trans "kcal" %} /+ <span id="value-energy-kjoule">{{ingredient.energy_kilojoule|floatformat:1}}</span> {% trans "kJ" %}</td></tr><tr>