From 04f9ac793552f0279a225732e794566d9946fa50 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Mon, 12 Aug 2024 22:37:41 +0200 Subject: [PATCH] Add a link for unpaid orders, disable the "zen" of not being able to code fast --- src/project/templates/index.html | 4 ++++ src/project/views.py | 7 ++++++- src/utils/view_utils.py | 7 +++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/project/templates/index.html b/src/project/templates/index.html index 2cc3490..1cc49e6 100644 --- a/src/project/templates/index.html +++ b/src/project/templates/index.html @@ -14,6 +14,10 @@ It is very much under construction.

+ {% for order in unpaid_orders %} +

You have an unpaid order: View Order ID {{ order.id }}

+ {% endfor %} + {% comment %}

diff --git a/src/project/views.py b/src/project/views.py index 7fbde77..b8813e6 100644 --- a/src/project/views.py +++ b/src/project/views.py @@ -4,6 +4,7 @@ from __future__ import annotations from typing import TYPE_CHECKING +from accounting.models import Order from django_view_decorator import view from utils.view_utils import render @@ -19,7 +20,11 @@ if TYPE_CHECKING: ) def index(request: HttpRequest) -> HttpResponse: """View to show the index page.""" - return render(request, "index.html") + unpaid_orders = Order.objects.filter(member=request.user) + + context = {"unpaid_orders": unpaid_orders} + + return render(request, "index.html", context=context) @view( diff --git a/src/utils/view_utils.py b/src/utils/view_utils.py index bb04192..652dcee 100644 --- a/src/utils/view_utils.py +++ b/src/utils/view_utils.py @@ -10,9 +10,11 @@ from typing import Any from django.contrib.sites.shortcuts import get_current_site from django.core.exceptions import FieldError from django.core.paginator import Paginator +from django.shortcuts import render as django_render from django.urls import reverse from zen_queries import queries_disabled -from zen_queries import render as zen_queries_render + +# from zen_queries import render as zen_queries_render # noqa: ERA001 if TYPE_CHECKING: from django.db.models import Model @@ -134,4 +136,5 @@ def render(request: HttpRequest, template_name: str, context: dict[str, Any] | N # otherwise django-zen-queries will complain about database queries. request.user.get_all_permissions() - return zen_queries_render(request, template_name, context) + # return zen_queries_render(request, template_name, context) # noqa: ERA001 + return django_render(request, template_name, context)