lnbits-legend/lnbits/extensions/subdomains/views.py

32 lines
957 B
Python
Raw Normal View History

2020-12-29 19:16:04 +01:00
from quart import g, abort, render_template
from lnbits.decorators import check_user_exists, validate_uuids
2020-12-29 19:16:04 +01:00
from http import HTTPStatus
from . import subdomains_ext
2020-12-29 19:16:04 +01:00
from .crud import get_domain
2020-12-31 18:50:16 +01:00
@subdomains_ext.route("/")
@validate_uuids(["usr"], required=True)
@check_user_exists()
async def index():
return await render_template("subdomains/index.html", user=g.user)
2020-12-29 19:16:04 +01:00
2020-12-31 18:50:16 +01:00
2020-12-29 19:16:04 +01:00
@subdomains_ext.route("/<domain_id>")
async def display(domain_id):
domain = await get_domain(domain_id)
if not domain:
abort(HTTPStatus.NOT_FOUND, "Domain does not exist.")
2020-12-31 18:50:16 +01:00
allowed_records = domain.allowed_record_types.replace('"', "").replace(" ", "").split(",")
2020-12-31 18:39:16 +01:00
print(allowed_records)
2020-12-29 19:16:04 +01:00
return await render_template(
"subdomains/display.html",
domain_id=domain.id,
domain_domain=domain.domain,
domain_desc=domain.description,
domain_cost=domain.cost,
2020-12-31 18:50:16 +01:00
domain_allowed_record_types=allowed_records,
2020-12-29 19:16:04 +01:00
)