From b773d9df58cb6f29a0a1123808e67ce92b258319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Sun, 19 Feb 2023 14:30:26 +0100 Subject: [PATCH] Allow filtering by game, edition, purchase from the session list --- CHANGELOG.md | 127 ------------------------- frontend/src/index.css | 6 +- games/templates/list_sessions.html | 145 +++++++++++++++++------------ games/urls.py | 6 -- games/views.py | 9 +- 5 files changed, 94 insertions(+), 199 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c98d5ed..5f134f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,133 +1,6 @@ ## Unreleased -## Improved -* game overview: improve how editions and purchases are displayed -* add purchase: only allow choosing purchases of selected edition - -## 1.5.1 / 2023-11-14 21:10+01:00 - -## Improved -* Disallow choosing non-game purchase as related purchase -* Improve display of purchases - -## 1.5.0 / 2023-11-14 19:27+01:00 - -## New -* Add stat for finished this year's games -* Add purchase types: - * Game (previously all of them were this type) - * DLC - * Season Pass - * Battle Pass - -## Fixed -* Order purchases by date on game view - -## 1.4.0 / 2023-11-09 21:01+01:00 - -### New -* More fields are now optional. This is to make it easier to add new items in bulk. - * Game: Wikidata ID - * Edition: Platform, Year - * Purchase: Platform - * Platform: Group - * Session: Device -* New fields: - * Game: Year Released - * To record original year of release - * Upon migration, this will be set to a year of any of the game's edition that has it set - * Purchase: Date Finished -* Editions are now unique combination of name and platform -* Add more stats: - * All finished games - * All finished 2023 games - * All finished games that were purchased this year - * Sessions (count) - * Days played - * Finished (count) - * Unfinished (count) - * Refunded (count) - * Backlog Decrease (count) -* New workflow: - * Adding Game, Edition, Purchase, and Session in a row is now much faster - -### Improved -* game overview: simplify playtime range display -* new session: order devices alphabetically -* ignore English articles when sorting names - * added a new sort_name field that gets automatically created -* automatically fill certain values in forms: - * new game: name and sort name after typing - * new edition: name, sort name, and year when selecting game - * new purchase: platform when selecting edition - -## 1.3.0 / 2023-11-05 15:09+01:00 - -### 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 - -### Fixed -* Correctly limit sessions to a single year for stats - -## 1.2.0 / 2023-11-01 20:18+01:00 - -### New -* Add yearly stats page (https://git.kucharczyk.xyz/lukas/timetracker/issues/15) - -### Enhancements -* Add a button to start session from game overview - -## 1.1.2 / 2023-10-13 16:30+02:00 - -### Enhancements -* Durations are formatted in a consisent manner across all pages - -### Fixes -* Game Overview: display duration when >1 hour instead of displaying 0 - -## 1.1.1 / 2023-10-09 20:52+02:00 - -### New -* Add notes section to game overview - -### Enhancements -* Make it possible to add any data on the game overview page - -## 1.1.0 / 2023-10-09 00:01+02:00 - -### New -* Add game overview page (https://git.kucharczyk.xyz/lukas/timetracker/issues/8) -* Add helper buttons next to datime fields -* Add copy button on Add session page to copy times between fields -* Change fonts to IBM Plex - -### Enhancements -* Improve form appearance -* Focus important fields on forms -* Use the same form when editing a session as when adding a session -* Change recent session view to current year instead of last 30 days -* Add a hacky way not to reload a page when starting or ending a session (https://git.kucharczyk.xyz/lukas/timetracker/issues/52) -* Improve session list (https://git.kucharczyk.xyz/lukas/timetracker/issues/53) - -### Fixes - -* Fix session being wrongly considered in progress if it had a certain amount of manual hours (https://git.kucharczyk.xyz/lukas/timetracker/issues/58) -* Fix bug when filtering only manual sessions (https://git.kucharczyk.xyz/lukas/timetracker/issues/51) - - -## 1.0.3 / 2023-02-20 17:16+01:00 - -* Add wikidata ID and year for editions -* Add icons for game, edition, purchase filters * Allow filtering by game, edition, purchase from the session list -* Allow editing filtered entities from session list ## 1.0.2 / 2023-02-18 21:48+01:00 diff --git a/frontend/src/index.css b/frontend/src/index.css index 6d7bc5b..2ff5f48 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -14,7 +14,11 @@ textarea { #session-table { display: grid; - grid-template-columns: 3fr 1fr repeat(2, 2fr) 0.5fr 1fr; + grid-template-columns: 3fr repeat(3, 1fr) 0.5fr 1fr; +} + +.purchase-name:hover > span:nth-child(2) { + @apply dark:text-slate-300 } #button-container button { diff --git a/games/templates/list_sessions.html b/games/templates/list_sessions.html index 7e20d92..02166a6 100644 --- a/games/templates/list_sessions.html +++ b/games/templates/list_sessions.html @@ -3,65 +3,92 @@ {% block title %}{{ title }}{% endblock title %} {% block content %} - {% if dataset.count >= 1 %} -
- - {% include 'components/button_start.html' with text=last.purchase title="Start session of last played game" only %} + - {% endif %} - {% if dataset.count != 0 %} - - - - - - - - - - - {% for data in dataset %} - - - - - - - {% endfor %} - -
NameDuration
- - {{ data.purchase.edition }} - - {{ data.duration_formatted }}
- {% else %} -
No sessions found.
- {% endif %} +
+
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" }}
+
+ {% if data.unfinished %} + Not finished yet. + {% elif data.duration_manual %} + -- + {% else %} + {{ data.timestamp_end | date:"d/m/Y H:i" }} + {% endif %} +
+
{{ data.duration_formatted }}{% if data.duration_manual %} + + + {% endif %}
+
+ {% if data.unfinished %} + + + + {% endif %} + + + + + + +
+ {% endfor %} +
{% endblock content %} diff --git a/games/urls.py b/games/urls.py index 9c6c706..093aded 100644 --- a/games/urls.py +++ b/games/urls.py @@ -93,10 +93,4 @@ urlpatterns = [ {"filter": "ownership_type"}, name="list_sessions_by_ownership_type", ), - path("stats/", views.stats, name="stats_current_year"), - path( - "stats/", - views.stats, - name="stats_by_year", - ), ] diff --git a/games/views.py b/games/views.py index 20f4cb2..73ccb28 100644 --- a/games/views.py +++ b/games/views.py @@ -253,12 +253,6 @@ def start_session_same_as_last(request, last_session_id: int): return redirect("list_sessions") -# def delete_session(request, session_id=None): -# session = Session.objects.get(id=session_id) -# session.delete() -# return redirect("list_sessions") - - def list_sessions( request, filter="", @@ -283,6 +277,9 @@ def list_sessions( 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)