Correctly display game that is used as filter

This commit is contained in:
Lukáš Kucharczyk 2023-01-16 17:24:34 +01:00
parent 6fa049e1b1
commit a851b5329a
3 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,8 @@
## Unreleased
* Fixed
* When filtering by game, the "Filtering by (...)" text would erroneously list an unrelated platform
## 0.2.3 / 2023-01-15 23:13+01:00 ## 0.2.3 / 2023-01-15 23:13+01:00
* Allow filtering by platform and game on session list (https://git.kucharczyk.xyz/lukas/timetracker/issues/32) * Allow filtering by platform and game on session list (https://git.kucharczyk.xyz/lukas/timetracker/issues/32)

View File

@ -10,11 +10,11 @@
{% if dataset.count >= 1 %} {% if dataset.count >= 1 %}
<div class="mb-4">Total playtime: {{ total_duration }} over {{ dataset.count }} sessions.</div> <div class="mb-4">Total playtime: {{ total_duration }} over {{ dataset.count }} sessions.</div>
{% endif %} {% endif %}
{% if purchase or platform %} {% if purchase or platform or game %}
<a class="text-red-400 inline" href="{% url 'list_sessions' %}"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 inline"> <a class="text-red-400 inline" href="{% url 'list_sessions' %}"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 inline">
<path stroke-linecap="round" stroke-linejoin="round" d="M9.75 9.75l4.5 4.5m0-4.5l-4.5 4.5M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /> <path stroke-linecap="round" stroke-linejoin="round" d="M9.75 9.75l4.5 4.5m0-4.5l-4.5 4.5M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg> </svg>
</a><span>Filtering by "{% firstof purchase platform %}"</span> </a><span>Filtering by "{% firstof purchase platform game %}"</span>
{% if purchase %}<a class="dark:text-white hover:underline block" href="{% url 'list_sessions_by_game' purchase.game.id %}">See all platforms</a>{% endif %} {% if purchase %}<a class="dark:text-white hover:underline block" href="{% url 'list_sessions_by_game' purchase.game.id %}">See all platforms</a>{% endif %}
{% endif %} {% endif %}
{% if dataset.count >= 1 %} {% if dataset.count >= 1 %}

View File

@ -63,7 +63,7 @@ def list_sessions(request, filter="", purchase_id="", platform_id="", game_id=""
context["platform"] = Platform.objects.get(id=platform_id) context["platform"] = Platform.objects.get(id=platform_id)
elif filter == "game": elif filter == "game":
dataset = Session.objects.filter(purchase__game=game_id) dataset = Session.objects.filter(purchase__game=game_id)
context["game"] = Platform.objects.get(id=game_id) context["game"] = Game.objects.get(id=game_id)
else: else:
dataset = Session.objects.all().order_by("-timestamp_start") dataset = Session.objects.all().order_by("-timestamp_start")