Commit f58a00fa authored by Lysander Trischler's avatar Lysander Trischler

View user shows diagram for body weights

parent d9c653d4
......@@ -741,6 +741,13 @@ if __name__ == "__main__":
else:
hourly[day.hour][day.discipline] += day.count
weights = self.db.query("""
SELECT date, grams/1000 AS kg
FROM weights
WHERE username = %s
ORDER BY date
LIMIT 0, 100""", username)
self.render("user.html",
user=self.application.users[username],
stats=self.db.query("""
......@@ -752,7 +759,8 @@ if __name__ == "__main__":
""", username),
disciplines=disciplines,
daily=daily,
hourly=hourly)
hourly=hourly,
weights=weights)
@route(r'/passwd')
class ChangeAPIPasswordHandler(BaseHandler):
......
......@@ -9,7 +9,7 @@
<dl>
<dt><label for=weight>Gewicht in kg</label></dt>
<dd>
<input type=number name=weight id=weight value="{{ format_weight(weight.grams) }}" maxlength=7 min=0 max=9001 placeholder="das Körpergewicht in Kilogramm" />
<input type=number name=weight id=weight value="{{ format_weight(weight.grams) }}" maxlength=10 min=0 max=300 placeholder="das Körpergewicht in Kilogramm" />
<p class=info>Körpergewicht in Kilogramm</p>
</dd>
......
{% extends base.html %}
{% block title %}Benutzerübersicht {{ user }}{% end %}
{% block head %}
{% if weights %}
<script type="text/javascript" src="{{ static_url("graph.js") }}"></script>
{% end %}
{% end %}
{% block content %}
<section>
<h1>Benutzerübersicht {{ user }}</h1>
......@@ -117,5 +122,25 @@
</table>
</section>
{% end %}
{% if weights %}
<section>
<h2>Gewichtsab- und zunahmen</h2>
<p>Die letzten 100 Messpunkte des aufgezeichneten Körpergewichts:</p>
<noscript><p class=warning>Für die Diagrammdarstellung des Körpergewichts
muss JavaScript aktiviert sein! Dazu bitte die Domain
<code>kraftwerk.lyse.isobeef.org</code> erlauben.</p></noscript>
<canvas id=weights width=500 height=400 />
<script type=text/javascript>
var data = [
{% for weight in weights %}
[{{ int(weight.date.strftime("%s")) * 1000 }}, {{ weight.kg }}],
{% end %}
]
var canvas = document.getElementById("weights");
WeightGraph.render(canvas.getContext("2d"), data, canvas.width - 100, canvas.height - 30);
</script>
</section>
{% end %}
</section>
{% end %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment