mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-19 09:44:52 +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">
|
||||
<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>
|
||||
|
||||
<button class="button"><i class="ph ph-magnifying-glass"></i></button>
|
||||
|
@ -30,6 +36,12 @@
|
|||
</nav>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% if user %}
|
||||
<div class="block">
|
||||
<h2 style="margin-bottom: 0;">{{ user.username }}</h2>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if scores %}
|
||||
<div class="table">
|
||||
<table>
|
||||
|
|
|
@ -12,8 +12,9 @@ blueprint = Blueprint("views", __name__)
|
|||
@blueprint.route("/")
|
||||
def index():
|
||||
diff_arg = request.args.get("diff", 0)
|
||||
ver_arg = request.args.get("ver", GAME_VERSION)
|
||||
user_arg = request.args.get("user", None)
|
||||
ver_arg = request.args.get("ver", GAME_VERSION).strip()
|
||||
user_arg = request.args.get("user", "").strip()
|
||||
user = None
|
||||
|
||||
scores = db.session.query(Scores).filter_by(difficulty=diff_arg)
|
||||
|
||||
|
@ -32,7 +33,8 @@ def index():
|
|||
.filter(Scores.score == subquery.c.min)
|
||||
)
|
||||
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)
|
||||
else:
|
||||
abort(404, "User not found")
|
||||
|
@ -44,7 +46,7 @@ def index():
|
|||
scores=scores,
|
||||
diff=int(diff_arg),
|
||||
ver=ver_arg,
|
||||
user=user_arg
|
||||
user=user
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue