Change update_session to template partial
Django CI/CD / test (push) Failing after 1m3s Details
Django CI/CD / build-and-push (push) Has been skipped Details

This commit is contained in:
Lukáš Kucharczyk 2024-01-10 14:10:13 +01:00
parent 242833f886
commit aa669710e1
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
6 changed files with 35 additions and 3 deletions

View File

@ -1,3 +1,4 @@
{% load django_htmx %}
<!DOCTYPE html>
<html lang="en">
{% load static %}
@ -12,6 +13,7 @@
{% endblock title %}
</title>
<script src="{% static 'js/htmx.min.js' %}"></script>
{% django_htmx_script %}
<link rel="stylesheet" href="{% static 'base.css' %}" />
</head>
<body class="dark" hx-indicator="#indicator">

View File

@ -30,6 +30,7 @@
</thead>
<tbody>
{% for data in dataset %}
{% partialdef session-row inline=True %}
<tr>
<td class="px-2 sm:px-4 md:px-6 md:py-2 purchase-name truncate max-w-20char md:max-w-40char">
<a class="underline decoration-slate-500 sm:decoration-2"
@ -59,6 +60,7 @@
</td>
<td class="px-2 sm:px-4 md:px-6 md:py-2 font-mono">{{ data.duration_formatted }}</td>
</tr>
{% endpartialdef %}
{% endfor %}
</tbody>
</table>

View File

@ -77,6 +77,8 @@ def update_session(request, session_id=None):
session = Session.objects.get(id=session_id)
session.finish_now()
session.save()
if request.htmx:
return render(request, "list_sessions.html#session-row")
return redirect("list_sessions")

22
poetry.lock generated
View File

@ -172,6 +172,24 @@ files = [
[package.dependencies]
Django = ">=3.2"
[[package]]
name = "django-template-partials"
version = "23.4"
description = "django-template-partials"
optional = false
python-versions = "*"
files = [
{file = "django-template-partials-23.4.tar.gz", hash = "sha256:f762b0b7b2222462df0845f0556792640b769eb832eae218a0e7dadd4e5606cc"},
{file = "django_template_partials-23.4-py2.py3-none-any.whl", hash = "sha256:d83d9c2d2836be769919e9aaf394d5feb1ac86e1187083030398308070122fca"},
]
[package.dependencies]
Django = "*"
[package.extras]
docs = ["Sphinx"]
tests = ["coverage", "django_coverage_plugin"]
[[package]]
name = "djhtml"
version = "1.5.2"
@ -986,5 +1004,5 @@ watchdog = ["watchdog (>=2.3)"]
[metadata]
lock-version = "2.0"
python-versions = "^3.12"
content-hash = "e864dc8abf6c84e5bb16ac2aa937c2a70561d15f3e8a1459866b9d6507e8773e"
python-versions = "^3.11"
content-hash = "c9ce052c193fdf4cc4b22f0cd1f2368fae6bc9304c38c770843315f39fa08de4"

View File

@ -8,7 +8,7 @@ readme = "README.md"
packages = [{include = "timetracker"}]
[tool.poetry.group.main.dependencies]
python = "^3.12"
python = "^3.11"
django = "^4.2.0"
gunicorn = "^20.1.0"
uvicorn = "^0.20.0"
@ -27,6 +27,10 @@ isort = "^5.11.4"
pre-commit = "^3.5.0"
django-debug-toolbar = "^4.2.0"
[tool.poetry.dependencies]
django-htmx = "^1.17.2"
django-template-partials = "^23.4"
[tool.isort]
profile = "black"

View File

@ -38,7 +38,9 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"template_partials",
"graphene_django",
"django_htmx",
]
GRAPHENE = {"SCHEMA": "games.schema.schema"}
@ -56,6 +58,7 @@ MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_htmx.middleware.HtmxMiddleware",
]
if DEBUG:
@ -79,6 +82,7 @@ TEMPLATES = [
"games.views.model_counts",
"games.views.stats_dropdown_year_range",
],
"builtins": ["template_partials.templatetags.partials"],
},
},
]