summaryrefslogtreecommitdiff
path: root/dashboard_website/dashboard.py
diff options
context:
space:
mode:
Diffstat (limited to 'dashboard_website/dashboard.py')
-rw-r--r--dashboard_website/dashboard.py36
1 files changed, 31 insertions, 5 deletions
diff --git a/dashboard_website/dashboard.py b/dashboard_website/dashboard.py
index ba29799..8ec53e0 100644
--- a/dashboard_website/dashboard.py
+++ b/dashboard_website/dashboard.py
@@ -172,10 +172,33 @@ def visitTeam():
# ERROR CODES: 1 = missing fields, 2 = clue doesn't exist, 3 = already marked as visited
def visitGeneric():
content = request.get_json()
+ unvisit = False
+ print(content)
+ if "unvisit" in content:
+ unvisit = True
+
if not ('clue_name' in content):
return jsonify({'status' : "ERROR 1"})
- result = db.visitClue(content['clue_name'])
+ result = db.visitClue(content['clue_name'], unvisit)
+ if result != 0:
+ return jsonify({'status' : f"ERROR {result}"})
+ return jsonify({'status' : "OK"})
+
+@app.route("/requireClue", methods=['POST'])
+# Expected JSON
+# {"clue_name" : xxxx, str}
+# Returns JSON
+# {"status" : "OK"/"ERROR XX" }
+# ERROR CODES: 1 = missing fields, 2 = clue doesn't exist, 3 = already marked as visited
+def requireClue():
+ content = request.get_json()
+ print(content)
+
+ if not ('clue_name' in content):
+ return jsonify({'status' : "ERROR 1"})
+
+ result = db.toggleClueRequired(content['clue_name'])
if result != 0:
return jsonify({'status' : f"ERROR {result}"})
return jsonify({'status' : "OK"})
@@ -236,11 +259,14 @@ def getLatestInfo():
@app.route("/addClue", methods=['POST'])
def addClueWeb():
content = request.get_json()
-
+ print("adding clue:", content)
if not ('clue_name' in content and 'longitude' in content and 'latitude' in content and 'clue_info' in content):
- return jsonify({'status' : "ERROR 1"})
- #db.addClue()
- return jsonify({'status' : "OK",})
+ return jsonify({'status' : "ERROR: INVALID CLUE JSON FORMAT"})
+ res = db.addClue(content['clue_name'], content['clue_info'], content['latitude'], content['longitude'])
+ if res == 0:
+ return jsonify({'status' : "OK",})
+ elif res == -1:
+ return jsonify({'status' : "CLUE NAME ALREADY EXISTS"})
# main page