mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-19 01:44:51 +00:00
Start adding user profiles along searches
This commit is contained in:
parent
e1d22d502d
commit
361d76f530
2 changed files with 19 additions and 5 deletions
|
@ -22,7 +22,13 @@
|
||||||
|
|
||||||
<span class="text-input">
|
<span class="text-input">
|
||||||
<label for="search">Username</label>
|
<label for="search">Username</label>
|
||||||
<input type="text" name="user" id="search" {% if user %}value="{{ user }}"{% endif %} autocomplete="off"/>
|
<input
|
||||||
|
type="text"
|
||||||
|
name="user"
|
||||||
|
id="search"
|
||||||
|
{% if user %}value="{{ user.username }}"{% endif %}
|
||||||
|
autocomplete="off"
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<button class="button"><i class="ph ph-magnifying-glass"></i></button>
|
<button class="button"><i class="ph ph-magnifying-glass"></i></button>
|
||||||
|
@ -30,6 +36,12 @@
|
||||||
</nav>
|
</nav>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if user %}
|
||||||
|
<div class="block">
|
||||||
|
<h2 style="margin-bottom: 0;">{{ user.username }}</h2>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if scores %}
|
{% if scores %}
|
||||||
<div class="table">
|
<div class="table">
|
||||||
<table>
|
<table>
|
||||||
|
|
|
@ -12,8 +12,9 @@ blueprint = Blueprint("views", __name__)
|
||||||
@blueprint.route("/")
|
@blueprint.route("/")
|
||||||
def index():
|
def index():
|
||||||
diff_arg = request.args.get("diff", 0)
|
diff_arg = request.args.get("diff", 0)
|
||||||
ver_arg = request.args.get("ver", GAME_VERSION)
|
ver_arg = request.args.get("ver", GAME_VERSION).strip()
|
||||||
user_arg = request.args.get("user", None)
|
user_arg = request.args.get("user", "").strip()
|
||||||
|
user = None
|
||||||
|
|
||||||
scores = db.session.query(Scores).filter_by(difficulty=diff_arg)
|
scores = db.session.query(Scores).filter_by(difficulty=diff_arg)
|
||||||
|
|
||||||
|
@ -32,7 +33,8 @@ def index():
|
||||||
.filter(Scores.score == subquery.c.min)
|
.filter(Scores.score == subquery.c.min)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if user := Users.query.filter_by(username=user_arg).first():
|
user = Users.query.filter_by(username=user_arg).first()
|
||||||
|
if user:
|
||||||
scores = scores.filter_by(user_id=user.id)
|
scores = scores.filter_by(user_id=user.id)
|
||||||
else:
|
else:
|
||||||
abort(404, "User not found")
|
abort(404, "User not found")
|
||||||
|
@ -44,7 +46,7 @@ def index():
|
||||||
scores=scores,
|
scores=scores,
|
||||||
diff=int(diff_arg),
|
diff=int(diff_arg),
|
||||||
ver=ver_arg,
|
ver=ver_arg,
|
||||||
user=user_arg
|
user=user
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue