Compare commits
No commits in common. "41a8cb58365dcf382bbbd6f68483ce2fa507261c" and "08cf19a69d2df9c8f709477943ada6985e8ae454" have entirely different histories.
41a8cb5836
...
08cf19a69d
6 changed files with 9 additions and 70 deletions
|
|
@ -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>
|
|
||||||
|
|
@ -1,20 +1,2 @@
|
||||||
{% extends "collector/base.html" %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<h1>[{{ teil.id }}] {{ teil.name }}</h1>
|
<h1>[{{ teil.id }}] {{ teil.name }}</h1>
|
||||||
Last Changed: {{ teil.modified | date:"Y-m-d H:i:s e" }}
|
Last Changed: {{ teil.modified }}
|
||||||
|
|
||||||
<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,7 +1,3 @@
|
||||||
{% extends "collector/base.html" %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
{% if teile_list %}
|
{% if teile_list %}
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -9,14 +5,14 @@
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'collector:detail' teil.id %}">
|
<a href="{% url 'collector:detail' teil.id %}">
|
||||||
<strong>[{{ teil.id }}]</strong> {{ teil.name }}
|
<strong>[{{ teil.id }}]</strong> {{ teil.name }}
|
||||||
</a> ({{ teil.modified | date:"Y-m-d H:i:s e" }})
|
</a> ({{ teil.modified }})
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
<p>Noch keine Teile da.</p>
|
<p>Keine Teile da.</p>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
@ -25,13 +21,3 @@
|
||||||
<input type="text" name="new_name" value="">
|
<input type="text" name="new_name" value="">
|
||||||
<input type="submit" name="submit" value="add new Teil">
|
<input type="submit" name="submit" value="add new Teil">
|
||||||
</form>
|
</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"
|
app_name = "collector"
|
||||||
|
|
||||||
urlpatterns = [
|
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("recorded/<int:pk>/", views.DetailView.as_view(), name="detail"),
|
||||||
path("enter/", views.enter, name="enter"),
|
path("enter/", views.enter, name="enter"),
|
||||||
path("all/", views.TeileListView.as_view(), name="list-all"),
|
path("all/", views.ListView.as_view(), name="all"),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
|
|
@ -12,23 +11,15 @@ from .models import Teil
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_TEILE_NUMBER = 10
|
class ListView(generic.ListView):
|
||||||
|
|
||||||
class TeileListView(generic.ListView):
|
|
||||||
template_name = "collector/index.html"
|
template_name = "collector/index.html"
|
||||||
context_object_name = "teile_list"
|
context_object_name = "teile_list"
|
||||||
|
|
||||||
def get_queryset(self) -> QuerySet:
|
def get_queryset(self) -> QuerySet:
|
||||||
return Teil.objects.order_by("-modified")
|
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(ListView):
|
||||||
|
|
||||||
|
|
||||||
class IndexView(TeileListView):
|
|
||||||
def get_queryset(self) -> QuerySet:
|
def get_queryset(self) -> QuerySet:
|
||||||
return super().get_queryset()[:10]
|
return super().get_queryset()[:10]
|
||||||
|
|
||||||
|
|
@ -37,12 +28,6 @@ class DetailView(generic.DetailView):
|
||||||
model = Teil
|
model = Teil
|
||||||
template_name = "collector/detail.html"
|
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:
|
def enter(request: HttpRequest) -> HttpResponse:
|
||||||
try:
|
try:
|
||||||
|
|
@ -51,4 +36,4 @@ def enter(request: HttpRequest) -> HttpResponse:
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warning("Teil already existed")
|
logger.warning("Teil already existed")
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse("collector:list"))
|
return HttpResponseRedirect(reverse("collector:index"))
|
||||||
|
|
|
||||||
2
justfile
2
justfile
|
|
@ -13,7 +13,7 @@ lint-django:
|
||||||
python -m django check
|
python -m django check
|
||||||
|
|
||||||
lint-woodpecker:
|
lint-woodpecker:
|
||||||
-woodpecker-cli lint .woodpecker/workflow.yaml
|
woodpecker-cli lint .woodpecker/workflow.yaml
|
||||||
|
|
||||||
serve:
|
serve:
|
||||||
python -m django runserver
|
python -m django runserver
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue