diff options
| author | Anson Bridges <bridges.anson@gmail.com> | 2024-11-05 15:38:54 -0500 |
|---|---|---|
| committer | Anson Bridges <bridges.anson@gmail.com> | 2024-11-05 15:38:54 -0500 |
| commit | 1cbe6a267628509c24d32b458363ddb74cb82838 (patch) | |
| tree | b933d41e17ab6456c58ccff749098ae426136876 /dashboard_website/dashboard.py | |
| parent | 411b7f175fb81aed6a9b050ce0872b376afe0431 (diff) | |
MMXXIV PROGRESS
Diffstat (limited to 'dashboard_website/dashboard.py')
| -rw-r--r-- | dashboard_website/dashboard.py | 36 |
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 |
