[chronojump-server] Use tasks



commit e4c06370e3a721506421dbeec5fc34521bcf211c
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu May 11 18:17:52 2017 +0200

    Use tasks

 chronojump-flask/chronojump_server.py       |   26 ++++++++++-----
 chronojump-flask/templates/player_list.html |   43 +++++++++++++++++++++++++++
 tables.txt                                  |    4 ++
 3 files changed, 64 insertions(+), 9 deletions(-)
---
diff --git a/chronojump-flask/chronojump_server.py b/chronojump-flask/chronojump_server.py
index 94d978a..fe5f7a9 100644
--- a/chronojump-flask/chronojump_server.py
+++ b/chronojump-flask/chronojump_server.py
@@ -40,37 +40,45 @@ def Results():
     if stationId is None or stationId == "" or stationId == "All":
         stationStr = ""
     else:
-        stationStr = " AND stationId = " + stationId;
+        stationStr = " AND stationId = " + stationId
     
     if personId is None or personId == "" or personId == "All":
-        personStr = "";
+        personStr = ""
     else:
-        personStr = " AND person.id = " + personId;
+        personStr = " AND person.id = " + personId
 
     cursor.execute("SELECT results.dt, person.name, station.name, results.resistance, results.exerciseName, 
results.meanPowerBestRep, results.repsAbove50pBest, results.comments" +
                 " FROM results, person, station " +
                 " WHERE results.personId = person.id " +
                 " AND results.stationId = station.id " +
                 personStr + dateStr + stationStr +
-                " ORDER by results.id DESC");
+                " ORDER by results.id DESC")
     results = cursor.fetchall()
         
     cursor.execute("SELECT results.personId, person.name FROM results, " +
-            "person WHERE results.personId = person.id GROUP BY person.id");
+            "person WHERE results.personId = person.id GROUP BY person.id")
     persons = cursor.fetchall()
 
-    cursor.execute("SELECT * FROM station");
+    cursor.execute("SELECT * FROM station")
     stations = cursor.fetchall()
 
     return render_template('results.html', header=getHeader("Resultats"), date=date, pId=personId, 
sId=stationId, results=results, persons=persons, stations=stations)
 
 @app.route('/player_list')
 def list():
+    p = request.args.get('p')
+
     cursor = mysql.connect().cursor()
-    cursor.execute("select * from person")
 
-    rows = cursor.fetchall(); 
-    return render_template("player_list.html", header = getHeader("Llistat de jugadors"), rows = rows)
+    if p is None or p == "" or p == "All":
+        cursor.execute("SELECT * FROM person")
+    elif p == "Task":
+        cursor.execute("SELECT person.*, task.id, task.comment FROM person, task WHERE task.id=person.id")
+    else:
+        cursor.execute("SELECT * FROM person") #TODO: select non-task persons
+
+    rows = cursor.fetchall()
+    return render_template("player_list.html", header = getHeader("Llistat de jugadors"), rows = rows, p=p)
 
 @app.route('/player_add')
 def player_add():
diff --git a/chronojump-flask/templates/player_list.html b/chronojump-flask/templates/player_list.html
index e83edf1..d09627f 100644
--- a/chronojump-flask/templates/player_list.html
+++ b/chronojump-flask/templates/player_list.html
@@ -6,9 +6,44 @@
                <link rel= "stylesheet" type= "text/css" href= "{{ 
url_for('static',filename='styles/input.css') }}">
        </head>
        <body>
+               {% if (not p or p == "") %}
+               {% set p = "All" %}
+               {% endif %}
+
                <div class="main">
                {{ header|safe }}
 
+               <form action=player_list>
+                       <div id="textbox"><p class="alignleft">
+                               <span class="noselect"> <!-- make values not selectable (highlight by cursor) 
-->
+                                       {% if p == "All" %}
+                                       <input type="radio" id="pAll" name="p" value="All" checked="checked">
+                                       {% else %}
+                                       <input type="radio" id="pAll" name="p" value="All">
+                                       {% endif %}
+                                       <label for="pAll">Tots</label>
+
+                                       {% if p == "Task" %}
+                                       <input type="radio" id="pTask" name="p" value="Task" 
checked="checked">
+                                       {% else %}
+                                       <input type="radio" id="pTask" name="p" value="Task">
+                                       {% endif %}
+                                       <label for="pTask">Amb tasca</label>
+
+                                       <!--
+                                       {% if p == "NoTask" %}
+                                       <input type="radio" id="pNoTask" name="p" value="NoTask" 
checked="checked">
+                                       {% else %}
+                                       <input type="radio" id="pNoTask" name="p" value="NoTask">
+                                       {% endif %}
+                                       <label for="pNoTask">Sense tasca</label>
+                                       -->
+                               </span>
+                               </p>
+                               <p class="alignright"><input type="submit" value="Actualitza"></p></div>
+                       <div style="clear: both;"></div>
+               </form>
+
                <table id="newspaper-a">
                        <thead>
                                <th>id</th>
@@ -16,6 +51,10 @@
                                <th>Pes</th>
                                <th>Alçada</th>
                                <th>RFID</th>
+                               {% if p == "Task" %}
+                               <th>Tasca Id</th>
+                               <th>Tasca</th>
+                               {% endif %}
                        </thead>
 
                        {% for row in rows %}
@@ -25,6 +64,10 @@
                                <td>{{row[2]}}</td>
                                <td>{{row[3]}}</td>     
                                <td>{{row[4]}}</td>
+                               {% if p == "Task" %}
+                               <td>{{row[5]}}</td>
+                               <td>{{row[6]}}</td>
+                               {% endif %}
                        </tr>
                        {% endfor %}
                </table>
diff --git a/tables.txt b/tables.txt
index 21c8d2a..ee58d65 100644
--- a/tables.txt
+++ b/tables.txt
@@ -14,6 +14,8 @@ CREATE TABLE rfid(dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP, personID INT NOT NULL,
 #rfid can be six numbers long (of three digits each), separated by commas
 CREATE TABLE person(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name CHAR(30), weight FLOAT, height FLOAT, 
rfid CHAR(23));
 
+CREATE TABLE task(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 
personID INT, comment CHAR(200));
+
 # 2.- insert sample data:
 
 insert into station VALUES(1, "Sprint");
@@ -26,5 +28,7 @@ insert into station VALUES(7, "Inercial 3");
 insert into station VALUES(8, "Dominades");
 insert into station VALUES(9, "Leg press");
 insert into person VALUES(NULL, "joan", 80, 175.7, "212,212,212,212");
+insert into person VALUES(NULL, "pep", 72, 164.4, "211,211,211,211");
 insert into results VALUES(NULL, NULL, 1, 2, 45.2, "press de banca", 480, 6, "");
 insert into results VALUES(NULL, NULL, 1, 1, 2, "sprint", NULL, NULL, "5 segons");
+insert into task VALUES(NULL, NULL, 1, "Mig squat amb 45 Kg, 3 series de 8 repeticions a 1,1 m/s. 
Desplaçaments laterals amb la inercial de 800 W");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]