feat(session): reset running session start time to now from list

Adds a confirm-gated button on running sessions in the session list that
sets timestamp_start to now (issue #33). The htmx path returns HX-Refresh;
ButtonGroup gains optional hx_confirm/hx_swap keys.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 20:37:44 +02:00
parent bf60a2a06b
commit 2a1585831f
7 changed files with 170 additions and 16 deletions
+32
View File
@@ -144,6 +144,24 @@ def list_sessions(request: HttpRequest, search_string: str = "") -> HttpResponse
}
if session.timestamp_end is None
else {},
{
"href": reverse(
"games:list_sessions_reset_session_start",
args=[session.pk],
),
"hx_get": reverse(
"games:list_sessions_reset_session_start",
args=[session.pk],
),
"hx_confirm": (
"Reset this session's start time to now?"
),
"slot": Icon("reset"),
"title": "Reset start to now",
"color": "gray",
}
if session.timestamp_end is None
else {},
{
"href": reverse(
"games:edit_session", args=[session.pk]
@@ -379,6 +397,20 @@ def end_session(request: HttpRequest, session_id: int) -> HttpResponse:
return redirect("games:list_sessions")
@login_required
def reset_session_start(request: HttpRequest, session_id: int) -> HttpResponse:
session = get_object_or_404(Session, id=session_id)
session.timestamp_start = timezone.now()
session.save()
if request.htmx:
# The list table is rebuilt server-side per request; a full refresh
# avoids swapping in a row fragment whose layout could drift from it.
response = HttpResponse(status=204)
response["HX-Refresh"] = "true"
return response
return redirect("games:list_sessions")
@login_required
def delete_session(request: HttpRequest, session_id: int = 0) -> HttpResponse:
session = get_object_or_404(Session, id=session_id)