Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Correct the PAL factor, texts and the BMI chart

Roland Geider0c13ab63582e
diff --git a/wger/manager/models.py b/wger/manager/models.py
index ae299660f..084cf850a 100644
--- a/wger/manager/models.py
+++ b/wger/manager/models.py
@@ -715,36 +715,40 @@ by the US Department of Agriculture. It is extremely complete, with around
def calculate_activities(self):
'''
Calculates the calories needed by additional physical activities
+
+ Factors taken from
+ * https://en.wikipedia.org/wiki/Physical_activity_level
+ * http://www.fao.org/docrep/007/y5686e/y5686e07.htm
'''
# Sleep
- sleep = self.sleep_hours * 1.9
+ sleep = self.sleep_hours * 0.95
# Work
if self.work_intensity == self.INTENSITY_LOW:
work_factor = 1.5
elif self.work_intensity == self.INTENSITY_MEDIUM:
- work_factor = 2
+ work_factor = 1.8
else:
- work_factor = 4
+ work_factor = 2.2
work = self.work_hours * work_factor
# Sport
# Sport is given in hours/week, so divide
if self.sport_intensity == self.INTENSITY_LOW:
- sport_factor = 3
+ sport_factor = 4
elif self.sport_intensity == self.INTENSITY_MEDIUM:
- sport_factor = 7
+ sport_factor = 6
else:
- sport_factor = 12
- sport = (self.sport_hours / 7) * sport_factor
+ sport_factor = 10
+ sport = (self.sport_hours / 7.0) * sport_factor
# Free time
if self.freetime_intensity == self.INTENSITY_LOW:
- freetime_factor = 2
+ freetime_factor = 1.3
elif self.freetime_intensity == self.INTENSITY_MEDIUM:
- freetime_factor = 4
+ freetime_factor = 1.9
else:
- freetime_factor = 6
+ freetime_factor = 2.4
freetime = self.freetime_hours * freetime_factor
# Total
diff --git a/wger/nutrition/templates/bmi/form.html b/wger/nutrition/templates/bmi/form.html
index 6b55c7790..2c0525fcf 100644
--- a/wger/nutrition/templates/bmi/form.html
+++ b/wger/nutrition/templates/bmi/form.html
@@ -62,10 +62,9 @@ $(document).ready(function () {
var area = d3.svg.area()
.interpolate("linear")
.x(function(d) { return x(d.height); })
- //.x(function(d) { return x(d.height); })
.y0(function(d) { return y(d.y0); })
- //.y1(function(d) { return y(d.y0 + d.y); });
- .y1(function(d) { return y(d.weight); });
+ .y1(function(d) { return y(d.y); });
+
var svg = d3.select("#bmi-chart").append("svg")
.attr("width", width + margin.left + margin.right)
@@ -86,13 +85,14 @@ $(document).ready(function () {
var layers = stack(nest.entries(data));
// Manually set the domains
- x.domain([150, 200]);
- y.domain([30, 180]);
+ x.domain([150, 200]); // height, in cm
+ y.domain([30, 160]); // weight, in kg
svg.selectAll(".layer")
.data(layers)
.enter().append("path")
.attr("class", "layer")
+ .attr("id", function(d, i) { return "key-" + d.key; })
.attr("clip-path", "url(#clip)")
.attr("d", function(d) { return area(d.values); })
.style("fill", function(d, i) { return z(i); })
@@ -104,6 +104,7 @@ $(document).ready(function () {
.call(xAxis);
svg.append("g")
+ //.attr("transform", "translate(" + width + ",0)")
.attr("class", "y axis")
.call(yAxis);
diff --git a/wger/nutrition/templates/rate/form.html b/wger/nutrition/templates/rate/form.html
index 36be70b57..5828b1219 100644
--- a/wger/nutrition/templates/rate/form.html
+++ b/wger/nutrition/templates/rate/form.html
@@ -70,9 +70,9 @@ $(document).ready(function() {
{% block content %}
<h3>1 - {%trans "Basal metabolic rate" %}</h3>
-<p>{% blocktrans %}Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-Integer et augue sem. Nullam bibendum tortor a lacus luctus tempor. Suspendisse
-auctor tristique metus, non ultricies quam.{% endblocktrans %}</p>
+<p>{% blocktrans %}The basal metabolic rate is the amount of energy expended daily
+at rest. This is the minimum energy needed for the body to function, without any
+additional physical activity.{% endblocktrans %}</p>
<form action="{% url 'calories-calculate' %}"
method="post"
class="ym-form calories-autoform"
@@ -110,9 +110,9 @@ auctor tristique metus, non ultricies quam.{% endblocktrans %}</p>
<h3>2 - {%trans "Physical activities" %}</h3>
-<p>{% blocktrans %}Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-Integer et augue sem. Nullam bibendum tortor a lacus luctus tempor. Suspendisse
-auctor tristique metus, non ultricies quam.{% endblocktrans %}</p>
+<p>{% blocktrans %}The physical activity level (PAL) is a factor used to to express
+the additional physical activity and is used to calculate the total energy
+required per day.{% endblocktrans %}</p>
<form action="{% url 'calories-calculate-activities' %}"
method="post"
class="ym-form calories-autoform"
@@ -220,7 +220,7 @@ you might just enter yourself the amount of calories if you know the value.{% en
{# #}
{% block sidebar %}
<h3>{% trans "Info" %}</h3>
-<p>{% blocktrans %}Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-Integer et augue sem. Nullam bibendum tortor a lacus luctus tempor. Suspendisse
-auctor tristique metus, non ultricies quam.{% endblocktrans %}</p>
+<p>{% blocktrans %}Please note that these calculations can only be an
+approximation. If you base your nutrition plan on these values, observe
+yourself for some weeks and change the total amount if needed.{% endblocktrans %}</p>
{% endblock %}
diff --git a/wger/nutrition/views/bmi.py b/wger/nutrition/views/bmi.py
index 84304446b..9dd67ffa2 100644
--- a/wger/nutrition/views/bmi.py
+++ b/wger/nutrition/views/bmi.py
@@ -98,29 +98,32 @@ def chart_data(request):
'''
data = json.dumps([
- {'key': 'severe_thinness', 'height': 150, 'weight': 22.5},
+ {'key': 'filler', 'height': 150, 'weight': 36},
+ {'key': 'filler', 'height': 200, 'weight': 64},
+
+ {'key': 'severe_thinness', 'height': 150, 'weight': 36},
{'key': 'severe_thinness', 'height': 200, 'weight': 64},
- {'key': 'moderate_thinness', 'height': 150, 'weight': 36},
- {'key': 'moderate_thinness', 'height': 200, 'weight': 68},
+ {'key': 'moderate_thinness', 'height': 150, 'weight': 36.25},
+ {'key': 'moderate_thinness', 'height': 200, 'weight': 64},
- {'key': 'mild_thinness', 'height': 150, 'weight': 36.25},
- {'key': 'mild_thinness', 'height': 200, 'weight': 68.5},
+ {'key': 'mild_thinness', 'height': 150, 'weight': 41.625},
+ {'key': 'mild_thinness', 'height': 200, 'weight': 74},
- {'key': 'normal_range', 'height': 150, 'weight': 41.625},
+ {'key': 'normal_range', 'height': 150, 'weight': 56.025},
{'key': 'normal_range', 'height': 200, 'weight': 99.6},
- {'key': 'pre_obese', 'height': 150, 'weight': 56.25},
+ {'key': 'pre_obese', 'height': 150, 'weight': 67.275},
{'key': 'pre_obese', 'height': 200, 'weight': 119.6},
- {'key': 'obese_class_1', 'height': 150, 'weight': 67.5},
+ {'key': 'obese_class_1', 'height': 150, 'weight': 78.525},
{'key': 'obese_class_1', 'height': 200, 'weight': 139.6},
- {'key': 'obese_class_2', 'height': 150, 'weight': 78.75},
+ {'key': 'obese_class_2', 'height': 150, 'weight': 89.775},
{'key': 'obese_class_2', 'height': 200, 'weight': 159},
- {'key': 'obese_class_3', 'height': 150, 'weight': 90},
- {'key': 'obese_class_3', 'height': 200, 'weight': 180}
+ {'key': 'obese_class_3', 'height': 150, 'weight': 190},
+ {'key': 'obese_class_3', 'height': 200, 'weight': 190}
])
# Return the results to the client
diff --git a/wger/nutrition/views/calculator.py b/wger/nutrition/views/calculator.py
index 9d1ff387a..8969b8217 100644
--- a/wger/nutrition/views/calculator.py
+++ b/wger/nutrition/views/calculator.py
@@ -118,7 +118,6 @@ def update_total(request):
data = []
- #form = DailyCaloriesForm()
form = DailyCaloriesForm(data=request.POST, instance=request.user.userprofile)
if form.is_valid():
form.save()