Compare commits
No commits in common. "4552cf7616fa2ce179b30e34e6f8c62420a5934f" and "e67aa3fda1858a57e642e2d1915a99d5b1cca30c" have entirely different histories.
4552cf7616
...
e67aa3fda1
|
@ -1,12 +1,9 @@
|
|||
## 1.3.0 / 2023-11-05 15:09+01:00
|
||||
## Unreleased
|
||||
|
||||
### New
|
||||
* Add Stats to the main navigation
|
||||
* Allow selecting year on the Stats page
|
||||
|
||||
### Improved
|
||||
* Make some pages redirect back instead to session list
|
||||
|
||||
### Improved
|
||||
* Make navigation more compact
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ RUN npm install && \
|
|||
|
||||
FROM python:3.10.9-slim-bullseye
|
||||
|
||||
ENV VERSION_NUMBER 1.3.0
|
||||
ENV VERSION_NUMBER 1.2.0
|
||||
ENV PROD 1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from common.time import format_duration, now as now_with_tz
|
||||
from common.time import format_duration
|
||||
from common.time import now as now_with_tz
|
||||
from datetime import datetime, timedelta
|
||||
from django.conf import settings
|
||||
from django.db.models import Sum, F
|
||||
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import redirect, render
|
||||
from django.urls import reverse
|
||||
from typing import Callable, Any
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from .forms import (
|
||||
|
@ -61,25 +61,6 @@ def update_session(request, session_id=None):
|
|||
return redirect("list_sessions")
|
||||
|
||||
|
||||
def use_custom_redirect(
|
||||
func: Callable[..., HttpResponse]
|
||||
) -> Callable[..., HttpResponse]:
|
||||
"""
|
||||
Will redirect to "return_path" session variable if set.
|
||||
"""
|
||||
|
||||
def wrapper(request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
|
||||
response = func(request, *args, **kwargs)
|
||||
if isinstance(response, HttpResponseRedirect) and (
|
||||
next_url := request.session.get("return_path")
|
||||
):
|
||||
return HttpResponseRedirect(next_url)
|
||||
return response
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@use_custom_redirect
|
||||
def edit_session(request, session_id=None):
|
||||
context = {}
|
||||
session = Session.objects.get(id=session_id)
|
||||
|
@ -92,7 +73,6 @@ def edit_session(request, session_id=None):
|
|||
return render(request, "add_session.html", context)
|
||||
|
||||
|
||||
@use_custom_redirect
|
||||
def edit_purchase(request, purchase_id=None):
|
||||
context = {}
|
||||
purchase = Purchase.objects.get(id=purchase_id)
|
||||
|
@ -105,7 +85,6 @@ def edit_purchase(request, purchase_id=None):
|
|||
return render(request, "add.html", context)
|
||||
|
||||
|
||||
@use_custom_redirect
|
||||
def edit_game(request, game_id=None):
|
||||
context = {}
|
||||
purchase = Game.objects.get(id=game_id)
|
||||
|
@ -140,11 +119,9 @@ def view_game(request, game_id=None):
|
|||
context["last_session"] = context["sessions"].first()
|
||||
context["first_session"] = context["sessions"].last()
|
||||
context["sessions_with_notes"] = context["sessions"].exclude(note="")
|
||||
request.session["return_path"] = request.path
|
||||
return render(request, "view_game.html", context)
|
||||
|
||||
|
||||
@use_custom_redirect
|
||||
def edit_platform(request, platform_id=None):
|
||||
context = {}
|
||||
purchase = Platform.objects.get(id=platform_id)
|
||||
|
@ -157,7 +134,6 @@ def edit_platform(request, platform_id=None):
|
|||
return render(request, "add.html", context)
|
||||
|
||||
|
||||
@use_custom_redirect
|
||||
def edit_edition(request, edition_id=None):
|
||||
context = {}
|
||||
edition = Edition.objects.get(id=edition_id)
|
||||
|
@ -170,7 +146,6 @@ def edit_edition(request, edition_id=None):
|
|||
return render(request, "add.html", context)
|
||||
|
||||
|
||||
@use_custom_redirect
|
||||
def start_game_session(request, game_id: int):
|
||||
last_session = (
|
||||
Session.objects.filter(purchase__edition__game_id=game_id)
|
||||
|
@ -325,7 +300,6 @@ def stats(request, year: int = 0):
|
|||
"spent_per_game": int(total_spent / all_purchased_this_year.count()),
|
||||
}
|
||||
|
||||
request.session["return_path"] = request.path
|
||||
return render(request, "stats.html", context)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "timetracker"
|
||||
version = "1.3.0"
|
||||
version = "1.2.0"
|
||||
description = "A simple time tracker."
|
||||
authors = ["Lukáš Kucharczyk <lukas@kucharczyk.xyz>"]
|
||||
license = "GPL"
|
||||
|
|
Loading…
Reference in New Issue