Compare commits

..

No commits in common. "465d958d9b3fb9c0c6b797431887e24658d9a5bb" and "2defdd465794217c4d5fb1591aa29ef5cf514800" have entirely different histories.

7 changed files with 5 additions and 31 deletions

View File

@ -1,7 +1,6 @@
## 0.2.1 / 2023-01-13 16:53+01:00
## Unreleased
* 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

View File

@ -6,7 +6,7 @@ RUN npm install && \
FROM python:3.10.9-alpine
ENV VERSION_NUMBER 0.2.0-2-gd8ece97
ENV VERSION_NUMBER 0.2.0
ENV PROD 1
RUN apk add \

View File

@ -20,7 +20,7 @@ migrate: makemigrations
poetry run python src/web/manage.py migrate
dev: migrate sethookdir
poetry run python src/web/manage.py runserver
poetry run python src/web/manage.py runserver_plus
caddy:
caddy run --watch

View File

@ -4,8 +4,6 @@ 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):
@ -59,9 +57,6 @@ 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)
@ -79,10 +74,6 @@ 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

View File

@ -3,18 +3,13 @@
{% block title %}Sessions{% endblock title %}
{% block content %}
<div class="text-center text-xl mb-4 dark:text-slate-400">
<a href="{% url 'start_session' dataset.last.purchase.id %}">
<button type="button" title="Track last tracked" class="py-1 px-2 bg-green-600 hover:bg-green-700 focus:ring-green-500 focus:ring-offset-blue-200 text-white transition ease-in duration-200 text-center text-base font-semibold shadow-md focus:outline-none focus:ring-2 focus:ring-offset-2 w-12 h-6 rounded-lg ">
New session of {{ dataset.last.purchase }}
</button>
</a>
{% if purchase %}
<div class="text-center text-xl mb-4 dark:text-slate-400">
<h1>Listing sessions only for purchase "{{ purchase }}"</h1>
<h2>Total playtime: {{ total_duration }} over {{ dataset.count }} sessions.</h2>
<a class="dark:text-white hover:underline" href="{% url 'list_sessions' %}">View all sessions</a>
{% endif %}
</div>
{% endif %}
<div id="session-table" class="gap-4 shadow rounded-xl max-w-screen-lg mx-auto dark:bg-slate-700 p-2 justify-center">
<div class="dark:border-white dark:text-slate-300 text-lg">Name</div>
<div class="dark:border-white dark:text-slate-300 text-lg text-center">Start</div>

View File

@ -12,11 +12,6 @@ urlpatterns = [
views.update_session,
name="update_session",
),
path(
"start-session/<int:purchase_id>",
views.start_session,
name="start_session",
),
path(
"delete_session/by-id/<int:session_id>",
views.delete_session,

View File

@ -40,12 +40,6 @@ def update_session(request, session_id=None):
return redirect("list_sessions")
def start_session(request, purchase_id=None):
session = SessionForm({"purchase": purchase_id, "timestamp_start": now_with_tz()})
session.save()
return redirect("list_sessions")
def delete_session(request, session_id=None):
session = Session.objects.get(id=session_id)
session.delete()