Ignore accounts without address, add user page

This commit is contained in:
dsc 2022-03-12 22:14:27 +02:00
parent cc0c35814f
commit 9a51c3c4fb
4 changed files with 59 additions and 2 deletions

View file

@ -13,7 +13,9 @@ async def api_root():
@bp_api.get('/user/')
async def api_all():
return jsonify([u.to_json(ignore_key='id') for u in User.select()])
q = User.select()
q = q.where(User.address.is_null(False))
return jsonify([u.to_json(ignore_key='id') for u in q])
@bp_api.get('/user/<path:needle>')

View file

@ -70,6 +70,19 @@ async def search():
return await render_template('search.html', users=users)
@bp_routes.route("/user/<path:name>")
async def user_page(name: str):
if not name or len(name) <= 1:
raise Exception("invalid name")
_user = User.select().where(
User.username == name,
User.address.is_null(False)
).get()
return await render_template('user.html', users=[_user])
@bp_routes.route("/about")
async def about():
return await render_template('about.html')

View file

@ -2,7 +2,7 @@
{% for user in users %}
<article>
<header>
<em>{{user.username}}</em>
<em><a href="{{ url_for('bp_routes.user_page', name=user.username) }}">{{user.username}}</a></em>
<small style="float: right">Added: {{ user.created_dt }}</small>
</header>
<kbd>{{user.address}}</kbd>

View file

@ -0,0 +1,42 @@
{% extends "base.html" %}
{% block content %}
<div style="display:none">
{% block title %}YellWOWPages - User{% endblock %}
</div>
<div id="main">
{% include 'includes/search.html' %}
{% if not users %}
<br>Nothing found...
{% else %}
{% include 'includes/user_results.html' %}
{% endif %}
</div>
<style>
#main{
width: 100%;
height: 80vh;
display: grid;
place-content: center;
}
form{
height: 80px;
}
#addresses{
width: 100%;
height: 50vh;
overflow-y: auto;
}
#addresses::-webkit-scrollbar{
display: none;
}
@media (max-width: 800px) {
kbd{
width: 100vw;
}
}
</style>
{% endblock %}