Converted views

This commit is contained in:
Ben Arc
2021-08-21 01:55:07 +01:00
parent d3d24abb17
commit bbdb96f4ac
21 changed files with 177 additions and 112 deletions
+13 -9
View File
@@ -5,17 +5,20 @@ from http import HTTPStatus
from . import subdomains_ext
from .crud import get_domain
from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates
templates = Jinja2Templates(directory="templates")
@subdomains_ext.get("/")
@validate_uuids(["usr"], required=True)
@check_user_exists()
async def index():
return await render_template("subdomains/index.html", user=g.user)
async def index(request: Request):
return await templates.TemplateResponse("subdomains/index.html", {"request":request,"user":g.user})
@subdomains_ext.get("/<domain_id>")
async def display(domain_id):
async def display(request: Request, domain_id):
domain = await get_domain(domain_id)
if not domain:
abort(HTTPStatus.NOT_FOUND, "Domain does not exist.")
@@ -23,11 +26,12 @@ async def display(domain_id):
domain.allowed_record_types.replace('"', "").replace(" ", "").split(",")
)
print(allowed_records)
return await render_template(
return await templates.TemplateResponse(
"subdomains/display.html",
domain_id=domain.id,
domain_domain=domain.domain,
domain_desc=domain.description,
domain_cost=domain.cost,
domain_allowed_record_types=allowed_records,
{"request":request,
"domain_id":domain.id,
"domain_domain":domain.domain,
"domain_desc":domain.description,
"domain_cost":domain.cost,
"domain_allowed_record_types":allowed_records}
)