[chronojump-server] Fixed when selected people or tasks are empty



commit afc4c118981573785745e60d7481ea2692bb6114
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 27 08:22:53 2017 +0200

    Fixed when selected people or tasks are empty

 main.py |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/main.py b/main.py
index 1767dca..fc57a3d 100755
--- a/main.py
+++ b/main.py
@@ -114,11 +114,13 @@ def getPersonByRFID():
     cur.execute("SELECT * FROM person where rfid = %s", (rfid, ))
     print(cur._last_executed)
     people = cur.fetchall()
+    print(people)
 
-    assert len(people) >= 1
-
-    # TODO: handle if len(people) == 0 (rfid not found)
-    return Response(json.dumps(people[0]))
+    if len(people) >= 1:
+        #assert len(people) >= 1
+        return Response(json.dumps(people[0]))
+    else:
+        return Response("", 202)
 
 @app.route("/getTasks", methods=['POST'])
 @auto.doc()
@@ -139,9 +141,11 @@ def getTasks():
 #        print(task[0])
 #        task[0] = unicode(task[0], errors='replace')
 
-    assert len(tasks) >= 1
-
-    return Response(json.dumps(tasks[0])) #TODO: download n tasks
+    if len(tasks) >= 1:
+        assert len(tasks) >= 1
+        return Response(json.dumps(tasks[0])) #TODO: download n tasks
+    else:
+        return Response("", 202)
 
 @app.route("/updateTask", methods=['POST'])
 @auto.doc()


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