Move from HTML templates to pure Python

Remove cruft
This commit is contained in:
2026-06-06 07:11:46 +02:00
parent 09db54e940
commit d101aecd70
109 changed files with 2903 additions and 2949 deletions
+57
View File
@@ -0,0 +1,57 @@
"""Authentication views rendered with the Python layout (replaces
registration/login.html)."""
from django.contrib.auth import views as auth_views
from django.http import HttpResponse
from django.utils.safestring import SafeText, mark_safe
from common.components import Component, CsrfInput, Div, Input
from common.layout import render_page
def _login_content(form, request) -> SafeText:
table = Component(
tag_name="table",
children=[
CsrfInput(request),
mark_safe(str(form.as_table())),
Component(
tag_name="tr",
children=[
Component(tag_name="td"),
Component(
tag_name="td",
children=[
Input(type="submit", attributes=[("value", "Login")])
],
),
],
),
],
)
return Div(
[("class", "flex items-center flex-col")],
[
Component(
tag_name="h2",
attributes=[("class", "text-3xl text-white mb-8")],
children=["Please log in to continue"],
),
Component(
tag_name="form",
attributes=[("method", "post")],
children=[table],
),
],
)
class LoginView(auth_views.LoginView):
"""Django's LoginView, but the page body is built in Python."""
def render_to_response(self, context, **response_kwargs) -> HttpResponse:
return render_page(
self.request,
_login_content(context["form"], self.request),
title="Login",
)