Ignore accounts without address, add user page
This commit is contained in:
parent
cc0c35814f
commit
9a51c3c4fb
|
@ -13,7 +13,9 @@ async def api_root():
|
||||||
|
|
||||||
@bp_api.get('/user/')
|
@bp_api.get('/user/')
|
||||||
async def api_all():
|
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>')
|
@bp_api.get('/user/<path:needle>')
|
||||||
|
|
|
@ -70,6 +70,19 @@ async def search():
|
||||||
return await render_template('search.html', users=users)
|
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")
|
@bp_routes.route("/about")
|
||||||
async def about():
|
async def about():
|
||||||
return await render_template('about.html')
|
return await render_template('about.html')
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<article>
|
<article>
|
||||||
<header>
|
<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>
|
<small style="float: right">Added: {{ user.created_dt }}</small>
|
||||||
</header>
|
</header>
|
||||||
<kbd>{{user.address}}</kbd>
|
<kbd>{{user.address}}</kbd>
|
||||||
|
|
|
@ -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 %}
|
Loading…
Reference in New Issue