From 6e078fe03d0600d62c01705970ecf044162b40fe Mon Sep 17 00:00:00 2001 From: bronsen Date: Sat, 15 Mar 2025 00:05:18 +0100 Subject: [PATCH 1/3] [just] ignore errors from linting workflow files This assumes the error stems from not having woodpecker-cli installed or not having it configured --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index 228b22f..7ae5614 100644 --- a/justfile +++ b/justfile @@ -13,7 +13,7 @@ lint-django: python -m django check lint-woodpecker: - woodpecker-cli lint .woodpecker/workflow.yaml + -woodpecker-cli lint .woodpecker/workflow.yaml serve: python -m django runserver From 3cd0aa39326dc7a01f57ae9e8861f671c9be537d Mon Sep 17 00:00:00 2001 From: bronsen Date: Sat, 15 Mar 2025 13:26:43 +0100 Subject: [PATCH 2/3] [collector] rename Views and urls --- collector/urls.py | 4 ++-- collector/views.py | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/collector/urls.py b/collector/urls.py index d12fc75..4b1c7bb 100644 --- a/collector/urls.py +++ b/collector/urls.py @@ -5,8 +5,8 @@ from . import views app_name = "collector" urlpatterns = [ - path("", views.IndexView.as_view(), name="index"), + path("", views.IndexView.as_view(), name="list"), path("recorded//", views.DetailView.as_view(), name="detail"), path("enter/", views.enter, name="enter"), - path("all/", views.ListView.as_view(), name="all"), + path("all/", views.TeileListView.as_view(), name="list-all"), ] diff --git a/collector/views.py b/collector/views.py index b77979a..cc6023d 100644 --- a/collector/views.py +++ b/collector/views.py @@ -1,4 +1,5 @@ import logging +from typing import Any from django.db import transaction from django.db.models import QuerySet @@ -11,15 +12,23 @@ from .models import Teil logger = logging.getLogger(__name__) -class ListView(generic.ListView): +DEFAULT_TEILE_NUMBER = 10 + +class TeileListView(generic.ListView): template_name = "collector/index.html" context_object_name = "teile_list" def get_queryset(self) -> QuerySet: return Teil.objects.order_by("-modified") + def get_context_data(self, **kwargs) -> dict[str, Any]: + context = super().get_context_data(**kwargs) + context["default_teile_number"] = DEFAULT_TEILE_NUMBER -class IndexView(ListView): + return context + + +class IndexView(TeileListView): def get_queryset(self) -> QuerySet: return super().get_queryset()[:10] @@ -28,6 +37,12 @@ class DetailView(generic.DetailView): model = Teil template_name = "collector/detail.html" + def get_context_data(self, **kwargs) -> dict[str, Any]: + context = super().get_context_data(**kwargs) + context["default_teile_number"] = DEFAULT_TEILE_NUMBER + + return context + def enter(request: HttpRequest) -> HttpResponse: try: @@ -36,4 +51,4 @@ def enter(request: HttpRequest) -> HttpResponse: except Exception: logger.warning("Teil already existed") - return HttpResponseRedirect(reverse("collector:index")) + return HttpResponseRedirect(reverse("collector:list")) From 41a8cb58365dcf382bbbd6f68483ce2fa507261c Mon Sep 17 00:00:00 2001 From: bronsen Date: Sat, 15 Mar 2025 13:27:19 +0100 Subject: [PATCH 3/3] [collector] templates now render html5 closes #6 --- collector/templates/collector/base.html | 14 ++++++++++++++ collector/templates/collector/detail.html | 20 +++++++++++++++++++- collector/templates/collector/index.html | 18 ++++++++++++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 collector/templates/collector/base.html diff --git a/collector/templates/collector/base.html b/collector/templates/collector/base.html new file mode 100644 index 0000000..da95fa5 --- /dev/null +++ b/collector/templates/collector/base.html @@ -0,0 +1,14 @@ + + + + + + Teilchensammler + + + + {% block content %} + + {% endblock content %} + + diff --git a/collector/templates/collector/detail.html b/collector/templates/collector/detail.html index 898dd8f..d78c2f0 100644 --- a/collector/templates/collector/detail.html +++ b/collector/templates/collector/detail.html @@ -1,2 +1,20 @@ +{% extends "collector/base.html" %} + +{% block content %} +

[{{ teil.id }}] {{ teil.name }}

-Last Changed: {{ teil.modified }} +Last Changed: {{ teil.modified | date:"Y-m-d H:i:s e" }} + +

+See the {{ default_teile_number }} most recent Teile. +

+ +

+See ALL the Teile in the database. +

+ +

+home +

+ +{% endblock content %} diff --git a/collector/templates/collector/index.html b/collector/templates/collector/index.html index 4611dff..ec294a8 100644 --- a/collector/templates/collector/index.html +++ b/collector/templates/collector/index.html @@ -1,3 +1,7 @@ +{% extends "collector/base.html" %} + +{% block content %} + {% if teile_list %} {% else %} -

Keine Teile da.

+

Noch keine Teile da.

{% endif %} @@ -21,3 +25,13 @@ + +

+See ALL the Teile in the dabase. +

+ +

+home +

+ +{% endblock content %}