Compare commits

...

3 commits

Author SHA1 Message Date
bronsen
41a8cb5836 [collector] templates now render html5
All checks were successful
ci/woodpecker/push/workflow/1 Pipeline was successful
ci/woodpecker/push/workflow/2 Pipeline was successful
closes #6
2025-03-15 13:28:41 +01:00
bronsen
3cd0aa3932 [collector] rename Views and urls 2025-03-15 13:28:41 +01:00
bronsen
6e078fe03d [just] ignore errors from linting workflow files
This assumes the error stems from not having woodpecker-cli installed or
not having it configured
2025-03-15 00:05:18 +01:00
6 changed files with 70 additions and 9 deletions

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Teilchensammler</title>
<!-- <link href="css/style.css" rel="stylesheet"> -->
</head>
<body>
{% block content %}
{% endblock content %}
</body>
</html>

View file

@ -1,2 +1,20 @@
{% extends "collector/base.html" %}
{% block content %}
<h1>[{{ teil.id }}] {{ teil.name }}</h1>
Last Changed: {{ teil.modified }}
Last Changed: {{ teil.modified | date:"Y-m-d H:i:s e" }}
<p>
See the <a href="{% url "collector:list" %}">{{ default_teile_number }} most recent Teile</a>.
</p>
<p>
See <a href="{% url "collector:list-all" %}"> ALL the Teile in the database</a>.
</p>
<p>
<a href="{% url "collector:list" %}">home</a>
</p>
{% endblock content %}

View file

@ -1,3 +1,7 @@
{% extends "collector/base.html" %}
{% block content %}
{% if teile_list %}
<ul>
@ -5,14 +9,14 @@
<li>
<a href="{% url 'collector:detail' teil.id %}">
<strong>[{{ teil.id }}]</strong> {{ teil.name }}
</a> ({{ teil.modified }})
</a> ({{ teil.modified | date:"Y-m-d H:i:s e" }})
</li>
{% endfor %}
</ul>
{% else %}
<p>Keine Teile da.</p>
<p>Noch keine Teile da.</p>
{% endif %}
@ -21,3 +25,13 @@
<input type="text" name="new_name" value="">
<input type="submit" name="submit" value="add new Teil">
</form>
<p>
See <a href="{% url "collector:list-all" %}">ALL the Teile in the dabase</a>.
</p>
<p>
<a href="{% url "collector:list" %}">home</a>
</p>
{% endblock content %}

View file

@ -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/<int:pk>/", 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"),
]

View file

@ -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"))

View file

@ -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