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 %}
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"))
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