Compare commits
3 commits
08cf19a69d
...
41a8cb5836
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41a8cb5836 | ||
|
|
3cd0aa3932 | ||
|
|
6e078fe03d |
6 changed files with 70 additions and 9 deletions
14
collector/templates/collector/base.html
Normal file
14
collector/templates/collector/base.html
Normal 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>
|
||||
|
|
@ -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 %}
|
||||
|
|
|
|||
|
|
@ -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 %}
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
|
|
|
|||
2
justfile
2
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue