mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-31 14:53:11 +00:00
Remake nav bar to work with more filters
Add new background work on fixing tables
This commit is contained in:
parent
1027361601
commit
459aefb124
15 changed files with 248 additions and 191 deletions
|
@ -1,22 +1,30 @@
|
|||
from flask import Blueprint, request, render_template
|
||||
from server.models import Scores
|
||||
from flask import Blueprint, request, render_template, abort
|
||||
from server.models import Scores, Users
|
||||
from server.config import GAME_VERSION
|
||||
|
||||
|
||||
blueprint = Blueprint("views", __name__)
|
||||
|
||||
|
||||
@blueprint.route("/")
|
||||
# @cache.cached(timeout=60)
|
||||
def index():
|
||||
difficulty = request.args.get("diff", 0)
|
||||
diff_arg = request.args.get("diff", 0)
|
||||
ver_arg = request.args.get("ver", GAME_VERSION)
|
||||
user_arg = request.args.get("user", "")
|
||||
|
||||
scores = (
|
||||
Scores.query.filter_by(difficulty=difficulty)
|
||||
.order_by(Scores.score.desc())
|
||||
.limit(10)
|
||||
.all()
|
||||
)
|
||||
return render_template("scores.html", scores=scores)
|
||||
scores = Scores.query.filter_by(difficulty=diff_arg)
|
||||
|
||||
if ver_arg:
|
||||
scores.filter_by(version=ver_arg)
|
||||
if user_arg:
|
||||
if user := Users.query.filter_by(username=user_arg).first():
|
||||
scores.filter_by(user_id=user.id)
|
||||
else:
|
||||
abort(404, "User not found")
|
||||
|
||||
scores.order_by(Scores.score.desc()).limit(10).all()
|
||||
|
||||
return render_template("scores.html", scores=scores, diff=int(diff_arg), ver=ver_arg, user=user_arg)
|
||||
|
||||
|
||||
@blueprint.route("/about")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue