+
Purchase
Platform
Start
End
Duration
Manage
{% for data in dataset %}
-
+
+
{{ data.purchase.edition }} ({{ data.purchase.get_ownership_type_display }})
+
+
+ (G,
+ E,
+ P,
+ O)
+
+
{{ data.timestamp_start | date:"d/m/Y H:i" }}
diff --git a/games/urls.py b/games/urls.py
index 0e276af..fbf626c 100644
--- a/games/urls.py
+++ b/games/urls.py
@@ -47,10 +47,22 @@ urlpatterns = [
{"filter": "platform"},
name="list_sessions_by_platform",
),
+ path(
+ "list-sessions/by-game/",
+ views.list_sessions,
+ {"filter": "game"},
+ name="list_sessions_by_game",
+ ),
path(
"list-sessions/by-edition/",
views.list_sessions,
{"filter": "edition"},
name="list_sessions_by_edition",
),
+ path(
+ "list-sessions/by-ownership/",
+ views.list_sessions,
+ {"filter": "ownership_type"},
+ name="list_sessions_by_ownership_type",
+ ),
]
diff --git a/games/views.py b/games/views.py
index 990e9ea..6fbcc76 100644
--- a/games/views.py
+++ b/games/views.py
@@ -110,7 +110,15 @@ def delete_session(request, session_id=None):
return redirect("list_sessions")
-def list_sessions(request, filter="", purchase_id="", platform_id="", edition_id=""):
+def list_sessions(
+ request,
+ filter="",
+ purchase_id="",
+ platform_id="",
+ game_id="",
+ edition_id="",
+ ownership_type: str = "",
+):
context = {}
context["title"] = "Sessions"
@@ -123,6 +131,12 @@ def list_sessions(request, filter="", purchase_id="", platform_id="", edition_id
elif filter == "edition":
dataset = Session.objects.filter(purchase__edition=edition_id)
context["edition"] = Edition.objects.get(id=edition_id)
+ elif filter == "game":
+ dataset = Session.objects.filter(purchase__edition__game=game_id)
+ context["game"] = Game.objects.get(id=game_id)
+ elif filter == "ownership_type":
+ dataset = Session.objects.filter(purchase__ownership_type=ownership_type)
+ context["ownership_type"] = dict(Purchase.OWNERSHIP_TYPES)[ownership_type]
elif filter == "recent":
dataset = Session.objects.filter(
timestamp_start__gte=datetime.now() - timedelta(days=30)