Skip to content

Commit

Permalink
Fixed bugs while inputting scores
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmatu committed Mar 6, 2022
1 parent 9f8040f commit 1bd256b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def mainpage():
return scores.get_user_scores()
else:
return redirect("/mainpage/allstats")
if request.method == "POST":
if check_valid_score:
scores.add_score()
return redirect("/")
if request.method == "POST":
if scores.check_valid_score():
scores.add_score()
return redirect("/")
else:
return render_template("/mainpage", error="Invalid value(s) while adding score. Please try again.")
return render_template("mainpage.html", error="Invalid value(s) while adding score. Please try again.")

@app.route("/game/<int:id>", methods = ["GET"])
def match(id):
Expand Down
6 changes: 3 additions & 3 deletions scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def add_score():
db.session.commit()

def check_valid_score():
if request.form["addaverage"] > 180:
if float(request.form["addaverage"]) > 180:
return False
if request.form["addtons"] > 5:
if int(request.form["addtons"]) > 5:
return False
if request.form["addhighest"] > 180:
if int(request.form["addhighest"]) > 180:
return False
return True

0 comments on commit 1bd256b

Please sign in to comment.