diff --git a/CHANGELOG.md b/CHANGELOG.md index cc33071..c0d2d51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ -## Unreleased +## 0.2.1 / 2023-01-13 16:53+01:00 * List number of sessions when filtering on session list +* Start sessions of last purchase from list (https://git.kucharczyk.xyz/lukas/timetracker/issues/19) ## 0.2.0 / 2023-01-09 22:42+01:00 diff --git a/Dockerfile b/Dockerfile index 01a4194..ef92893 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN npm install && \ FROM python:3.10.9-alpine -ENV VERSION_NUMBER 0.2.0-1-g2defdd4 +ENV VERSION_NUMBER 0.2.0-2-gd8ece97 ENV PROD 1 RUN apk add \ diff --git a/src/web/tracker/models.py b/src/web/tracker/models.py index 66095d7..01321e5 100644 --- a/src/web/tracker/models.py +++ b/src/web/tracker/models.py @@ -4,6 +4,8 @@ from django.conf import settings from zoneinfo import ZoneInfo from common.util.time import format_duration from django.db.models import Sum, F +from django.db.models import Manager +from typing import Any class Game(models.Model): @@ -57,6 +59,9 @@ class Session(models.Model): def finish_now(self): self.timestamp_end = datetime.now(ZoneInfo(settings.TIME_ZONE)) + def start_now(): + self.timestamp_start = datetime.now(ZoneInfo(settings.TIME_ZONE)) + def duration_seconds(self) -> timedelta: manual = timedelta(0) calculated = timedelta(0) @@ -74,6 +79,10 @@ class Session(models.Model): def duration_sum(self) -> str: return Session.objects.all().total_duration() + @property + def last(self) -> Manager[Any]: + return Session.objects.all().order_by("timestamp_start")[:-1] + def save(self, *args, **kwargs): if self.timestamp_start != None and self.timestamp_end != None: self.duration_calculated = self.timestamp_end - self.timestamp_start diff --git a/src/web/tracker/templates/list_sessions.html b/src/web/tracker/templates/list_sessions.html index a9b5dfd..74df365 100644 --- a/src/web/tracker/templates/list_sessions.html +++ b/src/web/tracker/templates/list_sessions.html @@ -3,13 +3,18 @@ {% block title %}Sessions{% endblock title %} {% block content %} - {% if purchase %}