From 6bf42ecba393a6e9482c50f52965ddd1bc8d54f8 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Sun, 28 Jul 2024 22:39:21 +0200 Subject: [PATCH] Bootstrap an Order detail page --- .../templates/accounting/order/detail.html | 13 +++++++ src/accounting/views.py | 38 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/accounting/templates/accounting/order/detail.html create mode 100644 src/accounting/views.py diff --git a/src/accounting/templates/accounting/order/detail.html b/src/accounting/templates/accounting/order/detail.html new file mode 100644 index 0000000..00c5989 --- /dev/null +++ b/src/accounting/templates/accounting/order/detail.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block head_title %} + {% trans "Order" %} +{% endblock %} + +{% block content %} + +
+

Order: {{ order.id }}

+
+{% endblock %} diff --git a/src/accounting/views.py b/src/accounting/views.py new file mode 100644 index 0000000..c31c5d9 --- /dev/null +++ b/src/accounting/views.py @@ -0,0 +1,38 @@ +"""Views for the membership app.""" + +from __future__ import annotations + +from typing import TYPE_CHECKING + +from django.shortcuts import render +from django_view_decorator import namespaced_decorator_factory + +from . import models + +if TYPE_CHECKING: + from django.http import HttpRequest + from django.http import HttpResponse + + +order_view = namespaced_decorator_factory(namespace="order", base_path="order") + + +@order_view( + paths="/", + name="detail", + login_required=True, +) +def order_detail(request: HttpRequest, order_id: int) -> HttpResponse: + """View to show the details of a member.""" + user = request.user # People just need to login to pay something, not necessarily be a member + order = models.Order.objects.get(pk=order_id, member=user) + + context = { + "order": order, + } + + return render( + request=request, + template_name="accounting/order/detail.html", + context=context, + )