Compare commits

..

No commits in common. "41a8cb58365dcf382bbbd6f68483ce2fa507261c" and "08cf19a69d2df9c8f709477943ada6985e8ae454" have entirely different histories.

6 changed files with 9 additions and 70 deletions

View file

@ -1,14 +0,0 @@
<!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,20 +1,2 @@
{% extends "collector/base.html" %}
{% block content %}
<h1>[{{ teil.id }}] {{ teil.name }}</h1>
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 %}
Last Changed: {{ teil.modified }}

View file

@ -1,7 +1,3 @@
{% extends "collector/base.html" %}
{% block content %}
{% if teile_list %}
<ul>
@ -9,14 +5,14 @@
<li>
<a href="{% url 'collector:detail' teil.id %}">
<strong>[{{ teil.id }}]</strong> {{ teil.name }}
</a> ({{ teil.modified | date:"Y-m-d H:i:s e" }})
</a> ({{ teil.modified }})
</li>
{% endfor %}
</ul>
{% else %}
<p>Noch keine Teile da.</p>
<p>Keine Teile da.</p>
{% endif %}
@ -25,13 +21,3 @@
<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="list"),
path("", views.IndexView.as_view(), name="index"),
path("recorded/<int:pk>/", views.DetailView.as_view(), name="detail"),
path("enter/", views.enter, name="enter"),
path("all/", views.TeileListView.as_view(), name="list-all"),
path("all/", views.ListView.as_view(), name="all"),
]

View file

@ -1,5 +1,4 @@
import logging
from typing import Any
from django.db import transaction
from django.db.models import QuerySet
@ -12,23 +11,15 @@ from .models import Teil
logger = logging.getLogger(__name__)
DEFAULT_TEILE_NUMBER = 10
class TeileListView(generic.ListView):
class ListView(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
return context
class IndexView(TeileListView):
class IndexView(ListView):
def get_queryset(self) -> QuerySet:
return super().get_queryset()[:10]
@ -37,12 +28,6 @@ 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:
@ -51,4 +36,4 @@ def enter(request: HttpRequest) -> HttpResponse:
except Exception:
logger.warning("Teil already existed")
return HttpResponseRedirect(reverse("collector:list"))
return HttpResponseRedirect(reverse("collector:index"))

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