mirror of
https://git.wownero.com/wownero/YellWOWPages.git
synced 2024-08-15 01:03:25 +00:00
71 lines
1.8 KiB
Python
71 lines
1.8 KiB
Python
from quart import render_template, request, redirect, url_for, jsonify, Blueprint, abort, flash, send_from_directory, session
|
|
|
|
from yellow import login_required
|
|
from yellow.factory import openid
|
|
from yellow.models import User
|
|
|
|
bp_routes = Blueprint('bp_routes', __name__)
|
|
|
|
|
|
@bp_routes.get("/")
|
|
async def root():
|
|
return await render_template('index.html')
|
|
|
|
|
|
@bp_routes.route("/login")
|
|
async def login():
|
|
return redirect(url_for(openid.endpoint_name_login))
|
|
|
|
|
|
@bp_routes.route("/logout")
|
|
@login_required
|
|
async def logout():
|
|
session['user'] = None
|
|
return redirect(url_for('bp_routes.root'))
|
|
|
|
|
|
@bp_routes.route("/dashboard")
|
|
@login_required
|
|
async def dashboard():
|
|
return await render_template('dashboard.html')
|
|
|
|
|
|
@bp_routes.post("/dashboard/address")
|
|
@login_required
|
|
async def dashboard_address_post():
|
|
# get FORM POST value 'address'
|
|
form = await request.form
|
|
address = form.get('address')
|
|
if len(address) != 97:
|
|
raise Exception("Please submit a WOW address")
|
|
|
|
# update user
|
|
from yellow.models import User
|
|
user = User.select().filter(User.id == session['user']['id']).get()
|
|
user.address = address
|
|
user.save()
|
|
session['user'] = user.to_json()
|
|
|
|
return await render_template('dashboard.html')
|
|
|
|
|
|
@bp_routes.route("/search")
|
|
async def search():
|
|
needle = request.args.get('username')
|
|
if needle:
|
|
if len(needle) <= 2:
|
|
raise Exception("Search term needs to be longer")
|
|
|
|
users = [u for u in await User.search(needle)]
|
|
if users:
|
|
return await render_template('search_results.html', users=users)
|
|
else:
|
|
return await render_template('search_results.html')
|
|
|
|
users = [u for u in User.select()]
|
|
return await render_template('search.html', users=users)
|
|
|
|
|
|
@bp_routes.route("/about")
|
|
async def about():
|
|
return await render_template('about.html')
|