From 4b451273351f779bec70a24ffcf94339ad5f1462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Wed, 4 Jan 2023 20:28:07 +0100 Subject: [PATCH] Allow deleting sessions --- CHANGELOG.md | 1 + Dockerfile | 2 +- src/web/tracker/static/base.css | 4 ++-- src/web/tracker/templates/list_sessions.html | 6 +++++- src/web/tracker/urls.py | 5 +++++ src/web/tracker/views.py | 6 ++++++ 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9a0b1a..55d55ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## Unreleased +* Allow deleting sessions * Redirect after adding game/platform/purchase/session * Fix display of duration_manual * Fix display of duration_calculated, display durations less than a minute diff --git a/Dockerfile b/Dockerfile index 281316a..b0d53a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,5 +12,5 @@ COPY entrypoint.sh / RUN chmod +x /entrypoint.sh USER timetracker EXPOSE 8000 -ENV VERSION_NUMBER 0.1.0-17-ga1309c3 +ENV VERSION_NUMBER 0.1.0-18-gb8a15e4 ENTRYPOINT [ "/entrypoint.sh" ] \ No newline at end of file diff --git a/src/web/tracker/static/base.css b/src/web/tracker/static/base.css index dfd4ac6..57e7241 100644 --- a/src/web/tracker/static/base.css +++ b/src/web/tracker/static/base.css @@ -766,8 +766,8 @@ select { max-width: 1024px; } -.grid-cols-4 { - grid-template-columns: repeat(4, minmax(0, 1fr)); +.grid-cols-5 { + grid-template-columns: repeat(5, minmax(0, 1fr)); } .flex-col { diff --git a/src/web/tracker/templates/list_sessions.html b/src/web/tracker/templates/list_sessions.html index 270b0de..a2f8dfd 100644 --- a/src/web/tracker/templates/list_sessions.html +++ b/src/web/tracker/templates/list_sessions.html @@ -9,11 +9,12 @@ View all sessions {% endif %} -
+
Name
Start
End
Duration
+
{% for data in dataset %}
{{ data.purchase }}
{{ data.timestamp_start | date:"d/m/Y H:i" }}
@@ -27,6 +28,9 @@ {% endif %}
{{ data.duration_formatted }}{% if data.duration_manual %} (M){% endif %}
+
+ +
{% endfor %}
{% endblock content %} \ No newline at end of file diff --git a/src/web/tracker/urls.py b/src/web/tracker/urls.py index 51af331..cb9c6e1 100644 --- a/src/web/tracker/urls.py +++ b/src/web/tracker/urls.py @@ -12,6 +12,11 @@ urlpatterns = [ views.update_session, name="update_session", ), + path( + "delete_session/by-id/", + views.delete_session, + name="delete_session", + ), path("add-purchase/", views.add_purchase, name="add_purchase"), path("list-sessions/", views.list_sessions, name="list_sessions"), path( diff --git a/src/web/tracker/views.py b/src/web/tracker/views.py index ef019ec..f100f16 100644 --- a/src/web/tracker/views.py +++ b/src/web/tracker/views.py @@ -37,6 +37,12 @@ def update_session(request, session_id=None): return redirect("list_sessions") +def delete_session(request, session_id=None): + session = Session.objects.get(id=session_id) + session.delete() + return redirect("list_sessions") + + def list_sessions(request, purchase_id=None): context = {}