From 2f00be455dc0969397bc0a9e6bccb3c48c3cb07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Thu, 19 Jan 2023 19:35:25 +0000 Subject: [PATCH] Rename project (#41) The old naming scheme was causing confusion and probably errors. Reviewed-on: https://git.kucharczyk.xyz/lukas/timetracker/pulls/41 --- .dockerignore | 2 +- .gitignore | 2 +- Caddyfile | 2 +- Dockerfile | 4 +- Makefile | 30 +- docker-compose.yml | 2 +- entrypoint.sh | 8 +- pyproject.toml | 1 + src/timelogger/timelogger.py | 3 - .../common/util}/__init__.py | 0 src/{web => timetracker}/common/util/plots.py | 2 +- src/{web => timetracker}/common/util/time.py | 0 .../util => timetracker/games}/__init__.py | 0 .../tracker => timetracker/games}/admin.py | 0 .../tracker => timetracker/games}/apps.py | 4 +- src/timetracker/games/fixtures/data.yaml | 1091 +++++++++++++++++ .../games}/fixtures/platforms.yaml | 14 +- src/timetracker/games/fixtures/sample.yaml | 71 ++ .../tracker => timetracker/games}/forms.py | 0 .../games}/migrations/0001_initial.py | 6 +- .../0002_alter_session_duration_manual.py | 2 +- ..._alter_session_duration_manual_and_more.py | 2 +- .../0004_alter_session_duration_manual.py | 2 +- .../migrations/0005_auto_20230109_1843.py | 6 +- .../migrations/0006_auto_20230109_1904.py | 6 +- ...e_game_alter_purchase_platform_and_more.py | 35 + .../games/migrations}/__init__.py | 0 .../tracker => timetracker/games}/models.py | 2 +- .../games}/static/base.css | 0 .../games}/templates/add.html | 0 .../games}/templates/base.html | 0 .../games}/templates/index.html | 0 .../games}/templates/list_sessions.html | 0 .../games}/templatetags/version.py | 0 .../tracker => timetracker/games}/tests.py | 0 .../tracker => timetracker/games}/urls.py | 0 .../tracker => timetracker/games}/views.py | 8 +- src/{web => timetracker}/manage.py | 2 +- .../root}/__init__.py | 0 src/{web/web => timetracker/root}/asgi.py | 4 +- src/{web/web => timetracker/root}/settings.py | 10 +- src/{web/web => timetracker/root}/urls.py | 4 +- src/{web/web => timetracker/root}/wsgi.py | 4 +- src/web/tracker/fixtures/sample.yaml | 98 -- src/web/web/__init__.py | 0 tests/test_time.py | 2 +- 46 files changed, 1266 insertions(+), 163 deletions(-) delete mode 100644 src/timelogger/timelogger.py rename src/{timelogger => timetracker/common/util}/__init__.py (100%) rename src/{web => timetracker}/common/util/plots.py (98%) rename src/{web => timetracker}/common/util/time.py (100%) rename src/{web/common/util => timetracker/games}/__init__.py (100%) rename src/{web/tracker => timetracker/games}/admin.py (100%) rename src/{web/tracker => timetracker/games}/apps.py (63%) create mode 100644 src/timetracker/games/fixtures/data.yaml rename src/{web/tracker => timetracker/games}/fixtures/platforms.yaml (62%) create mode 100644 src/timetracker/games/fixtures/sample.yaml rename src/{web/tracker => timetracker/games}/forms.py (100%) rename src/{web/tracker => timetracker/games}/migrations/0001_initial.py (96%) rename src/{web/tracker => timetracker/games}/migrations/0002_alter_session_duration_manual.py (92%) rename src/{web/tracker => timetracker/games}/migrations/0003_alter_session_duration_manual_and_more.py (90%) rename src/{web/tracker => timetracker/games}/migrations/0004_alter_session_duration_manual.py (86%) rename src/{web/tracker => timetracker/games}/migrations/0005_auto_20230109_1843.py (83%) rename src/{web/tracker => timetracker/games}/migrations/0006_auto_20230109_1904.py (84%) create mode 100644 src/timetracker/games/migrations/0007_alter_purchase_game_alter_purchase_platform_and_more.py rename src/{web/tracker => timetracker/games/migrations}/__init__.py (100%) rename src/{web/tracker => timetracker/games}/models.py (98%) rename src/{web/tracker => timetracker/games}/static/base.css (100%) rename src/{web/tracker => timetracker/games}/templates/add.html (100%) rename src/{web/tracker => timetracker/games}/templates/base.html (100%) rename src/{web/tracker => timetracker/games}/templates/index.html (100%) rename src/{web/tracker => timetracker/games}/templates/list_sessions.html (100%) rename src/{web/tracker => timetracker/games}/templatetags/version.py (100%) rename src/{web/tracker => timetracker/games}/tests.py (100%) rename src/{web/tracker => timetracker/games}/urls.py (100%) rename src/{web/tracker => timetracker/games}/views.py (97%) rename src/{web => timetracker}/manage.py (89%) rename src/{web/tracker/migrations => timetracker/root}/__init__.py (100%) rename src/{web/web => timetracker/root}/asgi.py (75%) rename src/{web/web => timetracker/root}/settings.py (95%) rename src/{web/web => timetracker/root}/urls.py (92%) rename src/{web/web => timetracker/root}/wsgi.py (73%) delete mode 100644 src/web/tracker/fixtures/sample.yaml delete mode 100644 src/web/web/__init__.py diff --git a/.dockerignore b/.dockerignore index 5587f2e..f2fd1b3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,4 +5,4 @@ .venv .vscode node_modules -src/web/static/* \ No newline at end of file +src/timetracker/static/* \ No newline at end of file diff --git a/.gitignore b/.gitignore index cb91e09..5e290c8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ __pycache__ node_modules package-lock.json db.sqlite3 -src/web/static \ No newline at end of file +src/timetracker/static \ No newline at end of file diff --git a/Caddyfile b/Caddyfile index 158438a..f95bb91 100644 --- a/Caddyfile +++ b/Caddyfile @@ -5,7 +5,7 @@ :8000 { handle_path /static/* { - root * src/web/static/ + root * src/timetracker/static/ file_server } handle { diff --git a/Dockerfile b/Dockerfile index 843641f..76897b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM node as css WORKDIR /app COPY . /app RUN npm install && \ - npx tailwindcss -i ./src/input.css -o ./src/web/tracker/static/base.css --minify + npx tailwindcss -i ./src/input.css -o ./src/timetracker/games/static/base.css --minify FROM python:3.10.9-slim-bullseye @@ -26,7 +26,7 @@ RUN useradd -m --uid 1000 timetracker WORKDIR /home/timetracker/app COPY . /home/timetracker/app/ RUN chown -R timetracker:timetracker /home/timetracker/app -COPY --from=css /app/src/web/tracker/static/base.css /home/timetracker/app/src/web/tracker/static/base.css +COPY --from=css /app/src/timetracker/games/static/base.css /home/timetracker/app/src/timetracker/games/static/base.css COPY entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/Makefile b/Makefile index 6f4257f..a769e13 100644 --- a/Makefile +++ b/Makefile @@ -2,49 +2,49 @@ all: css migrate initialize: npm css migrate sethookdir loadplatforms -HTMLFILES := $(shell find src/web/tracker/templates -type f) +HTMLFILES := $(shell find src/timetracker/games/templates -type f) npm: npm install css: src/input.css - npx tailwindcss -i ./src/input.css -o ./src/web/tracker/static/base.css + npx tailwindcss -i ./src/input.css -o ./src/timetracker/games/static/base.css css-dev: css - npx tailwindcss -i ./src/input.css -o ./src/web/tracker/static/base.css --watch + npx tailwindcss -i ./src/input.css -o ./src/timetracker/games/static/base.css --watch makemigrations: - poetry run python src/web/manage.py makemigrations + poetry run python src/timetracker/manage.py makemigrations migrate: makemigrations - poetry run python src/web/manage.py migrate + poetry run python src/timetracker/manage.py migrate dev: migrate - poetry run python src/web/manage.py runserver + poetry run python src/timetracker/manage.py runserver caddy: caddy run --watch dev-prod: migrate collectstatic - cd src/web/; PROD=1 poetry run python -m gunicorn --bind 0.0.0.0:8001 web.asgi:application -k uvicorn.workers.UvicornWorker + cd src/timetracker/; PROD=1 poetry run python -m gunicorn --bind 0.0.0.0:8001 root.asgi:application -k uvicorn.workers.UvicornWorker -dumptracker: - poetry run python src/web/manage.py dumpdata --format yaml tracker --output tracker_fixture.yaml +dumpgames: + poetry run python src/timetracker/manage.py dumpdata --format yaml games --output tracker_fixture.yaml loadplatforms: - poetry run python src/web/manage.py loaddata platforms.yaml + poetry run python src/timetracker/manage.py loaddata platforms.yaml loadsample: - poetry run python src/web/manage.py loaddata sample.yaml + poetry run python src/timetracker/manage.py loaddata sample.yaml createsuperuser: - poetry run python src/web/manage.py createsuperuser + poetry run python src/timetracker/manage.py createsuperuser shell: - poetry run python src/web/manage.py shell + poetry run python src/timetracker/manage.py shell collectstatic: - poetry run python src/web/manage.py collectstatic --clear --no-input + poetry run python src/timetracker/manage.py collectstatic --clear --no-input poetry.lock: pyproject.toml poetry install @@ -56,6 +56,6 @@ date: poetry run python -c 'import datetime; from zoneinfo import ZoneInfo; print(datetime.datetime.isoformat(datetime.datetime.now(ZoneInfo("Europe/Prague")), timespec="minutes", sep=" "))' cleanstatic: - rm -r src/web/static/* + rm -r src/timetracker/static/* clean: cleanstatic diff --git a/docker-compose.yml b/docker-compose.yml index 5934edb..4aad4bb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: - CSRF_TRUSTED_ORIGINS="https://tracker.kucharczyk.xyz" user: "1000" # volumes: - # - "db:/home/timetracker/app/src/web/db.sqlite3" + # - "db:/home/timetracker/app/src/timetracker/db.sqlite3" ports: - "8000:8000" restart: unless-stopped diff --git a/entrypoint.sh b/entrypoint.sh index 3fc77c9..9613b6a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,12 +2,12 @@ # Apply database migrations set -euo pipefail echo "Apply database migrations" -poetry run python src/web/manage.py migrate +poetry run python src/timetracker/manage.py migrate echo "Collect static files" -poetry run python src/web/manage.py collectstatic --clear --no-input +poetry run python src/timetracker/manage.py collectstatic --clear --no-input echo "Starting server" caddy start -cd src/web || exit -poetry run python -m gunicorn --bind 0.0.0.0:8001 web.asgi:application -k uvicorn.workers.UvicornWorker --access-logfile - --error-logfile - +cd src/timetracker || exit +poetry run python -m gunicorn --bind 0.0.0.0:8001 root.asgi:application -k uvicorn.workers.UvicornWorker --access-logfile - --error-logfile - diff --git a/pyproject.toml b/pyproject.toml index b064871..127984b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,7 @@ description = "A simple time tracker." authors = ["Lukáš Kucharczyk "] license = "GPL" readme = "README.md" +packages = [{include = "timetracker", from = "src"}] [tool.poetry.dependencies] python = "^3.10" diff --git a/src/timelogger/timelogger.py b/src/timelogger/timelogger.py deleted file mode 100644 index 25dbc66..0000000 --- a/src/timelogger/timelogger.py +++ /dev/null @@ -1,3 +0,0 @@ -import logging - -logging.basicConfig(level=logging.ERROR, filename="timelogger.log") diff --git a/src/timelogger/__init__.py b/src/timetracker/common/util/__init__.py similarity index 100% rename from src/timelogger/__init__.py rename to src/timetracker/common/util/__init__.py diff --git a/src/web/common/util/plots.py b/src/timetracker/common/util/plots.py similarity index 98% rename from src/web/common/util/plots.py rename to src/timetracker/common/util/plots.py index 4bd258b..47e5f9c 100644 --- a/src/web/common/util/plots.py +++ b/src/timetracker/common/util/plots.py @@ -7,7 +7,7 @@ import matplotlib.dates as mdates import pandas as pd from django.db.models import F, IntegerField, QuerySet, Sum from django.db.models.functions import TruncDay -from tracker.models import Session +from games.models import Session def key_value_to_value_value(data): diff --git a/src/web/common/util/time.py b/src/timetracker/common/util/time.py similarity index 100% rename from src/web/common/util/time.py rename to src/timetracker/common/util/time.py diff --git a/src/web/common/util/__init__.py b/src/timetracker/games/__init__.py similarity index 100% rename from src/web/common/util/__init__.py rename to src/timetracker/games/__init__.py diff --git a/src/web/tracker/admin.py b/src/timetracker/games/admin.py similarity index 100% rename from src/web/tracker/admin.py rename to src/timetracker/games/admin.py diff --git a/src/web/tracker/apps.py b/src/timetracker/games/apps.py similarity index 63% rename from src/web/tracker/apps.py rename to src/timetracker/games/apps.py index 37951d5..4c4fb1d 100644 --- a/src/web/tracker/apps.py +++ b/src/timetracker/games/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -class TrackerConfig(AppConfig): +class GamesConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "tracker" + name = "games" diff --git a/src/timetracker/games/fixtures/data.yaml b/src/timetracker/games/fixtures/data.yaml new file mode 100644 index 0000000..c2ff658 --- /dev/null +++ b/src/timetracker/games/fixtures/data.yaml @@ -0,0 +1,1091 @@ +- model: games.game + pk: 1 + fields: + name: Nioh 2 + wikidata: Q67482292 +- model: games.game + pk: 2 + fields: + name: Elden Ring + wikidata: Q64826862 +- model: games.game + pk: 3 + fields: + name: Cyberpunk 2077 + wikidata: Q3182559 +- model: games.game + pk: 4 + fields: + name: Xenoblade Chronicles + wikidata: Q1287714 +- model: games.game + pk: 5 + fields: + name: Shin Megami Tensei V + wikidata: Q44379841 +- model: games.game + pk: 6 + fields: + name: Forspoken + wikidata: Q96240948 +- model: games.game + pk: 7 + fields: + name: Metal Hellsinger + wikidata: Q96252758 +- model: games.game + pk: 8 + fields: + name: Valkyrie Elysium + wikidata: Q111200610 +- model: games.game + pk: 9 + fields: + name: God of War Ragnarök + wikidata: Q99397916 +- model: games.game + pk: 10 + fields: + name: 'Metal Gear Solid V: Ground Zeroes' + wikidata: Q11879017 +- model: games.game + pk: 11 + fields: + name: Grand Theft Auto V + wikidata: Q17452 +- model: games.game + pk: 12 + fields: + name: 'Wo Long: Fallen Dynasty' + wikidata: Q112566486 +- model: games.game + pk: 13 + fields: + name: Tony Hawk's Pro Skater 1 + 2 + wikidata: Q94587084 +- model: games.game + pk: 14 + fields: + name: Final Fantasy VII + wikidata: Q214232 +- model: games.game + pk: 15 + fields: + name: Final Fantasy VII Remake + wikidata: Q20155152 +- model: games.game + pk: 16 + fields: + name: Stray + wikidata: Q96247255 +- model: games.game + pk: 17 + fields: + name: 'Metal Gear Solid V: The Phantom Pain' + wikidata: Q717600 +- model: games.game + pk: 18 + fields: + name: Atelier Ayesha ~The Alchemist of Dusk~ + wikidata: Q4813026 +- model: games.purchase + pk: 1 + fields: + game: 1 + platform: 1 + date_purchased: 2021-02-13 + date_refunded: null +- model: games.purchase + pk: 2 + fields: + game: 2 + platform: 1 + date_purchased: 2022-02-24 + date_refunded: null +- model: games.purchase + pk: 3 + fields: + game: 3 + platform: 1 + date_purchased: 2020-12-07 + date_refunded: null +- model: games.purchase + pk: 4 + fields: + game: 4 + platform: 9 + date_purchased: 2023-01-10 + date_refunded: null +- model: games.purchase + pk: 5 + fields: + game: 5 + platform: 9 + date_purchased: 2023-01-10 + date_refunded: null +- model: games.purchase + pk: 6 + fields: + game: 1 + platform: 5 + date_purchased: 2022-11-19 + date_refunded: null +- model: games.purchase + pk: 7 + fields: + game: 6 + platform: 5 + date_purchased: 2022-12-10 + date_refunded: null +- model: games.purchase + pk: 8 + fields: + game: 7 + platform: 5 + date_purchased: 2022-12-11 + date_refunded: null +- model: games.purchase + pk: 9 + fields: + game: 8 + platform: 5 + date_purchased: 2022-12-11 + date_refunded: null +- model: games.purchase + pk: 10 + fields: + game: 9 + platform: 5 + date_purchased: 2022-11-11 + date_refunded: null +- model: games.purchase + pk: 11 + fields: + game: 10 + platform: 1 + date_purchased: 2019-12-01 + date_refunded: null +- model: games.purchase + pk: 12 + fields: + game: 11 + platform: 5 + date_purchased: 2022-03-22 + date_refunded: null +- model: games.purchase + pk: 13 + fields: + game: 12 + platform: 5 + date_purchased: 2022-09-18 + date_refunded: null +- model: games.purchase + pk: 14 + fields: + game: 13 + platform: 5 + date_purchased: 2022-08-17 + date_refunded: null +- model: games.purchase + pk: 15 + fields: + game: 14 + platform: 5 + date_purchased: 2022-07-26 + date_refunded: null +- model: games.purchase + pk: 16 + fields: + game: 15 + platform: 5 + date_purchased: 2022-01-16 + date_refunded: null +- model: games.purchase + pk: 17 + fields: + game: 16 + platform: 5 + date_purchased: 2022-07-19 + date_refunded: null +- model: games.purchase + pk: 18 + fields: + game: 17 + platform: 1 + date_purchased: 2019-01-12 + date_refunded: null +- model: games.purchase + pk: 19 + fields: + game: 18 + platform: 5 + date_purchased: 2022-07-03 + date_refunded: null +- model: games.platform + pk: 1 + fields: + name: Steam + group: PC +- model: games.platform + pk: 2 + fields: + name: Xbox Gamepass + group: PC +- model: games.platform + pk: 4 + fields: + name: Epic Games Store + group: PC +- model: games.platform + pk: 5 + fields: + name: Playstation 5 + group: Playstation +- model: games.platform + pk: 6 + fields: + name: Playstation 4 + group: Playstation +- model: games.platform + pk: 7 + fields: + name: Nintendo Switch + group: Nintendo +- model: games.platform + pk: 8 + fields: + name: Nintendo 3DS + group: Nintendo +- model: games.platform + pk: 9 + fields: + name: Yuzu + group: Emulator +- model: games.session + pk: 25 + fields: + purchase: 3 + timestamp_start: 2019-12-31 23:00:00+00:00 + timestamp_end: null + duration_manual: '12:00:00' + duration_calculated: 00:00:00 + note: '' +- model: games.session + pk: 26 + fields: + purchase: 2 + timestamp_start: 2022-12-31 14:25:00+00:00 + timestamp_end: 2022-12-31 16:25:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:00:00 + note: '' +- model: games.session + pk: 27 + fields: + purchase: 3 + timestamp_start: 2023-01-01 22:00:00+00:00 + timestamp_end: 2023-01-01 23:28:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:28:00 + note: '' +- model: games.session + pk: 28 + fields: + purchase: 3 + timestamp_start: 2023-01-02 21:08:00+00:00 + timestamp_end: 2023-01-03 00:08:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 03:00:00 + note: '' +- model: games.session + pk: 29 + fields: + purchase: 3 + timestamp_start: 2023-01-03 21:36:00+00:00 + timestamp_end: 2023-01-03 23:12:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:36:00 + note: '' +- model: games.session + pk: 30 + fields: + purchase: 3 + timestamp_start: 2023-01-04 19:35:00+00:00 + timestamp_end: 2023-01-04 21:36:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:01:00 + note: '' +- model: games.session + pk: 31 + fields: + purchase: 3 + timestamp_start: 2023-01-06 17:48:00+00:00 + timestamp_end: 2023-01-06 22:39:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 04:51:00 + note: '' +- model: games.session + pk: 32 + fields: + purchase: 3 + timestamp_start: 2023-01-07 22:49:00+00:00 + timestamp_end: 2023-01-08 00:43:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:54:00 + note: '' +- model: games.session + pk: 33 + fields: + purchase: 3 + timestamp_start: 2023-01-08 15:21:00+00:00 + timestamp_end: 2023-01-08 17:27:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:06:00 + note: '' +- model: games.session + pk: 34 + fields: + purchase: 3 + timestamp_start: 2023-01-08 18:04:00+00:00 + timestamp_end: 2023-01-08 21:03:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:59:00 + note: '' +- model: games.session + pk: 35 + fields: + purchase: 3 + timestamp_start: 2023-01-09 18:35:48+00:00 + timestamp_end: 2023-01-09 21:13:20.519058+00:00 + duration_manual: 00:00:00 + duration_calculated: '02:37:32.519058' + note: '' +- model: games.session + pk: 36 + fields: + purchase: 4 + timestamp_start: 2023-01-10 14:50:12+00:00 + timestamp_end: 2023-01-10 16:03:45.424429+00:00 + duration_manual: 00:00:00 + duration_calculated: '01:13:33.424429' + note: '' +- model: games.session + pk: 37 + fields: + purchase: 5 + timestamp_start: 2023-01-10 16:05:32+00:00 + timestamp_end: 2023-01-10 16:12:42.417912+00:00 + duration_manual: 00:00:00 + duration_calculated: '00:07:10.417912' + note: '' +- model: games.session + pk: 38 + fields: + purchase: 3 + timestamp_start: 2023-01-10 16:59:33+00:00 + timestamp_end: 2023-01-10 19:38:32.848575+00:00 + duration_manual: 00:00:00 + duration_calculated: '02:38:59.848575' + note: '' +- model: games.session + pk: 39 + fields: + purchase: 3 + timestamp_start: 2023-01-11 17:10:41+00:00 + timestamp_end: 2023-01-11 20:28:18.457008+00:00 + duration_manual: 00:00:00 + duration_calculated: '03:17:37.457008' + note: '' +- model: games.session + pk: 40 + fields: + purchase: 3 + timestamp_start: 2023-01-12 18:26:50+00:00 + timestamp_end: 2023-01-12 20:49:12.263807+00:00 + duration_manual: 00:00:00 + duration_calculated: '02:22:22.263807' + note: '' +- model: games.session + pk: 41 + fields: + purchase: 3 + timestamp_start: 2023-01-13 14:27:35+00:00 + timestamp_end: 2023-01-13 15:10:22.347944+00:00 + duration_manual: 00:00:00 + duration_calculated: '00:42:47.347944' + note: '' +- model: games.session + pk: 42 + fields: + purchase: 3 + timestamp_start: 2023-01-13 16:30:20.198534+00:00 + timestamp_end: 2023-01-13 21:00:16.376286+00:00 + duration_manual: 00:00:00 + duration_calculated: '04:29:56.177752' + note: '' +- model: games.session + pk: 43 + fields: + purchase: 2 + timestamp_start: 2021-12-31 23:00:00+00:00 + timestamp_end: null + duration_manual: 9 00:25:00 + duration_calculated: 00:00:00 + note: '' +- model: games.session + pk: 44 + fields: + purchase: 3 + timestamp_start: 2023-01-14 08:29:13.515133+00:00 + timestamp_end: 2023-01-14 15:29:00.504799+00:00 + duration_manual: 00:00:00 + duration_calculated: '06:59:46.989666' + note: '' +- model: games.session + pk: 45 + fields: + purchase: 3 + timestamp_start: 2023-01-14 16:18:26.228000+00:00 + timestamp_end: 2023-01-14 20:34:42.565242+00:00 + duration_manual: 00:00:00 + duration_calculated: '04:16:16.337242' + note: '' +- model: games.session + pk: 46 + fields: + purchase: 6 + timestamp_start: 2022-11-25 20:01:00+00:00 + timestamp_end: 2022-11-25 20:43:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:42:00 + note: '' +- model: games.session + pk: 47 + fields: + purchase: 6 + timestamp_start: 2022-11-25 20:46:00+00:00 + timestamp_end: 2022-11-25 21:56:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:10:00 + note: '' +- model: games.session + pk: 48 + fields: + purchase: 6 + timestamp_start: 2022-11-26 13:18:00+00:00 + timestamp_end: 2022-11-26 15:28:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:10:00 + note: '' +- model: games.session + pk: 49 + fields: + purchase: 6 + timestamp_start: 2022-12-03 22:26:00+00:00 + timestamp_end: 2022-12-04 01:01:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:35:00 + note: '' +- model: games.session + pk: 50 + fields: + purchase: 6 + timestamp_start: 2022-12-04 14:48:00+00:00 + timestamp_end: 2022-12-04 17:31:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:43:00 + note: '' +- model: games.session + pk: 51 + fields: + purchase: 6 + timestamp_start: 2022-12-06 18:43:00+00:00 + timestamp_end: 2022-12-06 22:16:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 03:33:00 + note: '' +- model: games.session + pk: 52 + fields: + purchase: 6 + timestamp_start: 2022-12-07 19:03:00+00:00 + timestamp_end: 2022-12-07 19:57:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:54:00 + note: '' +- model: games.session + pk: 53 + fields: + purchase: 6 + timestamp_start: 2022-12-08 20:14:00+00:00 + timestamp_end: 2022-12-08 22:16:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:02:00 + note: '' +- model: games.session + pk: 54 + fields: + purchase: 6 + timestamp_start: 2022-12-10 13:44:00+00:00 + timestamp_end: 2022-12-10 16:29:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:45:00 + note: '' +- model: games.session + pk: 55 + fields: + purchase: 7 + timestamp_start: 2022-12-10 16:29:00+00:00 + timestamp_end: 2022-12-10 17:10:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:41:00 + note: '' +- model: games.session + pk: 56 + fields: + purchase: 6 + timestamp_start: 2022-12-10 22:11:00+00:00 + timestamp_end: 2022-12-10 22:26:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:15:00 + note: '' +- model: games.session + pk: 57 + fields: + purchase: 6 + timestamp_start: 2022-12-10 22:31:00+00:00 + timestamp_end: 2022-12-10 23:50:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:19:00 + note: '' +- model: games.session + pk: 58 + fields: + purchase: 8 + timestamp_start: 2022-12-10 23:50:00+00:00 + timestamp_end: 2022-12-11 00:07:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:17:00 + note: '' +- model: games.session + pk: 59 + fields: + purchase: 9 + timestamp_start: 2022-12-11 00:07:00+00:00 + timestamp_end: 2022-12-11 00:20:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:13:00 + note: '' +- model: games.session + pk: 60 + fields: + purchase: 6 + timestamp_start: 2022-12-11 15:01:00+00:00 + timestamp_end: 2022-12-11 17:21:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:20:00 + note: '' +- model: games.session + pk: 61 + fields: + purchase: 6 + timestamp_start: 2022-12-12 20:41:00+00:00 + timestamp_end: 2022-12-12 22:34:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:53:00 + note: '' +- model: games.session + pk: 62 + fields: + purchase: 6 + timestamp_start: 2022-12-14 20:25:00+00:00 + timestamp_end: 2022-12-14 21:57:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:32:00 + note: '' +- model: games.session + pk: 63 + fields: + purchase: 6 + timestamp_start: 2022-12-17 13:34:00+00:00 + timestamp_end: 2022-12-17 16:53:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 03:19:00 + note: '' +- model: games.session + pk: 64 + fields: + purchase: 10 + timestamp_start: 2022-11-24 17:03:00+00:00 + timestamp_end: 2022-11-24 19:32:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:29:00 + note: '' +- model: games.session + pk: 65 + fields: + purchase: 10 + timestamp_start: 2022-11-22 18:41:00+00:00 + timestamp_end: 2022-11-23 01:52:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 07:11:00 + note: '' +- model: games.session + pk: 66 + fields: + purchase: 10 + timestamp_start: 2022-11-21 16:52:00+00:00 + timestamp_end: 2022-11-21 22:51:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 05:59:00 + note: '' +- model: games.session + pk: 67 + fields: + purchase: 10 + timestamp_start: 2022-11-20 20:11:00+00:00 + timestamp_end: 2022-11-20 23:13:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 03:02:00 + note: '' +- model: games.session + pk: 68 + fields: + purchase: 10 + timestamp_start: 2022-11-20 15:34:00+00:00 + timestamp_end: 2022-11-20 16:50:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:16:00 + note: '' +- model: games.session + pk: 69 + fields: + purchase: 10 + timestamp_start: 2022-11-19 21:46:00+00:00 + timestamp_end: 2022-11-19 23:52:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:06:00 + note: '' +- model: games.session + pk: 70 + fields: + purchase: 10 + timestamp_start: 2022-11-19 08:30:00+00:00 + timestamp_end: 2022-11-19 10:14:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:44:00 + note: '' +- model: games.session + pk: 71 + fields: + purchase: 10 + timestamp_start: 2022-11-18 17:15:00+00:00 + timestamp_end: 2022-11-18 22:16:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 05:01:00 + note: '' +- model: games.session + pk: 72 + fields: + purchase: 10 + timestamp_start: 2022-11-18 13:58:00+00:00 + timestamp_end: 2022-11-18 14:40:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:42:00 + note: '' +- model: games.session + pk: 73 + fields: + purchase: 10 + timestamp_start: 2022-11-17 21:50:00+00:00 + timestamp_end: 2022-11-18 00:25:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:35:00 + note: '' +- model: games.session + pk: 74 + fields: + purchase: 10 + timestamp_start: 2022-11-17 13:36:00+00:00 + timestamp_end: 2022-11-17 18:26:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 04:50:00 + note: '' +- model: games.session + pk: 75 + fields: + purchase: 10 + timestamp_start: 2022-11-17 07:16:00+00:00 + timestamp_end: 2022-11-17 10:13:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:57:00 + note: '' +- model: games.session + pk: 76 + fields: + purchase: 10 + timestamp_start: 2022-11-16 15:45:00+00:00 + timestamp_end: 2022-11-16 16:38:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:53:00 + note: '' +- model: games.session + pk: 77 + fields: + purchase: 10 + timestamp_start: 2022-11-15 18:14:00+00:00 + timestamp_end: 2022-11-15 22:28:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 04:14:00 + note: '' +- model: games.session + pk: 78 + fields: + purchase: 10 + timestamp_start: 2022-11-14 19:33:00+00:00 + timestamp_end: 2022-11-14 23:06:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 03:33:00 + note: '' +- model: games.session + pk: 79 + fields: + purchase: 10 + timestamp_start: 2022-11-13 18:37:00+00:00 + timestamp_end: 2022-11-13 22:43:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 04:06:00 + note: '' +- model: games.session + pk: 80 + fields: + purchase: 10 + timestamp_start: 2022-11-12 17:32:00+00:00 + timestamp_end: 2022-11-12 21:45:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 04:13:00 + note: '' +- model: games.session + pk: 81 + fields: + purchase: 10 + timestamp_start: 2022-11-11 21:17:00+00:00 + timestamp_end: 2022-11-11 23:00:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:43:00 + note: '' +- model: games.session + pk: 82 + fields: + purchase: 1 + timestamp_start: 2021-12-31 23:00:00+00:00 + timestamp_end: null + duration_manual: 1 23:54:00 + duration_calculated: 00:00:00 + note: '' +- model: games.session + pk: 83 + fields: + purchase: 11 + timestamp_start: 2019-12-01 23:00:00+00:00 + timestamp_end: null + duration_manual: 00:55:00 + duration_calculated: 00:00:00 + note: '' +- model: games.session + pk: 84 + fields: + purchase: 11 + timestamp_start: 2023-01-15 18:27:33+00:00 + timestamp_end: 2023-01-15 20:02:39.845888+00:00 + duration_manual: 00:00:00 + duration_calculated: '01:35:06.845888' + note: '' +- model: games.session + pk: 86 + fields: + purchase: 12 + timestamp_start: 2022-10-02 11:01:00+00:00 + timestamp_end: 2022-10-02 11:23:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:22:00 + note: '' +- model: games.session + pk: 87 + fields: + purchase: 12 + timestamp_start: 2022-10-01 22:59:00+00:00 + timestamp_end: 2022-10-02 00:54:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:55:00 + note: '' +- model: games.session + pk: 88 + fields: + purchase: 12 + timestamp_start: 2022-09-30 07:40:00+00:00 + timestamp_end: 2022-09-30 11:50:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 04:10:00 + note: '' +- model: games.session + pk: 89 + fields: + purchase: 12 + timestamp_start: 2022-09-27 07:38:00+00:00 + timestamp_end: 2022-09-27 09:16:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:38:00 + note: '' +- model: games.session + pk: 90 + fields: + purchase: 12 + timestamp_start: 2022-09-27 04:27:00+00:00 + timestamp_end: 2022-09-27 06:09:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:42:00 + note: '' +- model: games.session + pk: 91 + fields: + purchase: 12 + timestamp_start: 2022-09-26 05:58:00+00:00 + timestamp_end: 2022-09-26 08:38:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:40:00 + note: '' +- model: games.session + pk: 92 + fields: + purchase: 12 + timestamp_start: 2022-09-25 08:56:00+00:00 + timestamp_end: 2022-09-25 11:36:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 02:40:00 + note: '' +- model: games.session + pk: 93 + fields: + purchase: 12 + timestamp_start: 2022-09-24 23:57:00+00:00 + timestamp_end: 2022-09-25 01:38:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:41:00 + note: '' +- model: games.session + pk: 94 + fields: + purchase: 12 + timestamp_start: 2022-09-24 11:04:00+00:00 + timestamp_end: 2022-09-24 11:12:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:08:00 + note: '' +- model: games.session + pk: 95 + fields: + purchase: 12 + timestamp_start: 2022-09-23 05:33:00+00:00 + timestamp_end: 2022-09-23 08:38:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 03:05:00 + note: '' +- model: games.session + pk: 96 + fields: + purchase: 13 + timestamp_start: 2022-09-18 00:26:00+00:00 + timestamp_end: 2022-09-18 01:58:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:32:00 + note: '' +- model: games.session + pk: 97 + fields: + purchase: 12 + timestamp_start: 2022-08-30 09:42:00+00:00 + timestamp_end: 2022-08-30 10:15:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:33:00 + note: '' +- model: games.session + pk: 98 + fields: + purchase: 12 + timestamp_start: 2022-08-17 22:43:00+00:00 + timestamp_end: 2022-08-18 00:12:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:29:00 + note: '' +- model: games.session + pk: 99 + fields: + purchase: 12 + timestamp_start: 2022-08-17 09:42:00+00:00 + timestamp_end: 2022-08-17 10:58:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:16:00 + note: '' +- model: games.session + pk: 100 + fields: + purchase: 14 + timestamp_start: 2022-08-17 09:40:00+00:00 + timestamp_end: 2022-08-17 09:42:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:02:00 + note: '' +- model: games.session + pk: 101 + fields: + purchase: 14 + timestamp_start: 2022-08-14 00:46:00+00:00 + timestamp_end: 2022-08-14 01:10:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:24:00 + note: '' +- model: games.session + pk: 102 + fields: + purchase: 15 + timestamp_start: 2022-07-26 03:56:00+00:00 + timestamp_end: 2022-07-26 05:22:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:26:00 + note: '' +- model: games.session + pk: 103 + fields: + purchase: 16 + timestamp_start: 2022-07-26 02:39:00+00:00 + timestamp_end: 2022-07-26 03:53:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:14:00 + note: '' +- model: games.session + pk: 104 + fields: + purchase: 16 + timestamp_start: 2022-07-25 07:12:00+00:00 + timestamp_end: 2022-07-25 13:37:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 06:25:00 + note: '' +- model: games.session + pk: 105 + fields: + purchase: 16 + timestamp_start: 2022-07-23 09:09:00+00:00 + timestamp_end: 2022-07-23 14:33:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 05:24:00 + note: '' +- model: games.session + pk: 106 + fields: + purchase: 16 + timestamp_start: 2022-07-23 08:34:00+00:00 + timestamp_end: 2022-07-23 08:48:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:14:00 + note: '' +- model: games.session + pk: 107 + fields: + purchase: 16 + timestamp_start: 2022-07-23 03:05:00+00:00 + timestamp_end: 2022-07-23 04:44:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:39:00 + note: '' +- model: games.session + pk: 108 + fields: + purchase: 16 + timestamp_start: 2022-07-22 02:07:00+00:00 + timestamp_end: 2022-07-22 10:48:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 08:41:00 + note: '' +- model: games.session + pk: 109 + fields: + purchase: 16 + timestamp_start: 2022-07-22 00:26:00+00:00 + timestamp_end: 2022-07-22 00:59:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:33:00 + note: '' +- model: games.session + pk: 110 + fields: + purchase: 16 + timestamp_start: 2022-07-21 06:27:00+00:00 + timestamp_end: 2022-07-21 07:43:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:16:00 + note: '' +- model: games.session + pk: 111 + fields: + purchase: 16 + timestamp_start: 2022-07-21 05:48:00+00:00 + timestamp_end: 2022-07-21 05:58:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:10:00 + note: '' +- model: games.session + pk: 112 + fields: + purchase: 17 + timestamp_start: 2022-07-20 10:24:00+00:00 + timestamp_end: 2022-07-20 11:34:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 01:10:00 + note: '' +- model: games.session + pk: 113 + fields: + purchase: 17 + timestamp_start: 2022-07-19 08:49:00+00:00 + timestamp_end: 2022-07-19 12:24:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 03:35:00 + note: '' +- model: games.session + pk: 115 + fields: + purchase: 11 + timestamp_start: 2023-01-18 16:29:53.226199+00:00 + timestamp_end: 2023-01-18 17:59:25.814759+00:00 + duration_manual: 00:00:00 + duration_calculated: '01:29:32.588560' + note: '' +- model: games.session + pk: 116 + fields: + purchase: 18 + timestamp_start: 2023-01-18 18:32:02+00:00 + timestamp_end: 2023-01-18 21:29:53.302342+00:00 + duration_manual: 00:00:00 + duration_calculated: '02:57:51.302342' + note: '' +- model: games.session + pk: 117 + fields: + purchase: 19 + timestamp_start: 2022-07-03 18:26:00+00:00 + timestamp_end: 2022-07-03 18:34:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:08:00 + note: '' +- model: games.session + pk: 118 + fields: + purchase: 19 + timestamp_start: 2022-07-01 14:20:00+00:00 + timestamp_end: 2022-07-01 14:46:00+00:00 + duration_manual: 00:00:00 + duration_calculated: 00:26:00 + note: '' \ No newline at end of file diff --git a/src/web/tracker/fixtures/platforms.yaml b/src/timetracker/games/fixtures/platforms.yaml similarity index 62% rename from src/web/tracker/fixtures/platforms.yaml rename to src/timetracker/games/fixtures/platforms.yaml index b769fe5..dc09961 100644 --- a/src/web/tracker/fixtures/platforms.yaml +++ b/src/timetracker/games/fixtures/platforms.yaml @@ -1,28 +1,28 @@ -- model: tracker.Platform +- model: games.Platform fields: name: Steam group: PC -- model: tracker.Platform +- model: games.Platform fields: name: Xbox Gamepass group: PC -- model: tracker.Platform +- model: games.Platform fields: name: Epic Games Store group: PC -- model: tracker.Platform +- model: games.Platform fields: name: Playstation 5 group: Playstation -- model: tracker.Platform +- model: games.Platform fields: name: Playstation 4 group: Playstation -- model: tracker.Platform +- model: games.Platform fields: name: Nintendo Switch group: Nintendo -- model: tracker.Platform +- model: games.Platform fields: name: Nintendo 3DS group: Nintendo \ No newline at end of file diff --git a/src/timetracker/games/fixtures/sample.yaml b/src/timetracker/games/fixtures/sample.yaml new file mode 100644 index 0000000..5cbef3f --- /dev/null +++ b/src/timetracker/games/fixtures/sample.yaml @@ -0,0 +1,71 @@ +- model: games.game + pk: 1 + fields: + name: Nioh 2 + wikidata: Q67482292 +- model: games.game + pk: 2 + fields: + name: Elden Ring + wikidata: Q64826862 +- model: games.game + pk: 3 + fields: + name: Cyberpunk 2077 + wikidata: Q3182559 +- model: games.purchase + pk: 1 + fields: + game: 1 + platform: 1 + date_purchased: 2021-02-13 + date_refunded: null +- model: games.purchase + pk: 2 + fields: + game: 2 + platform: 1 + date_purchased: 2022-02-24 + date_refunded: null +- model: games.purchase + pk: 3 + fields: + game: 3 + platform: 1 + date_purchased: 2020-12-07 + date_refunded: null +- model: games.platform + pk: 1 + fields: + name: Steam + group: PC +- model: games.platform + pk: 3 + fields: + name: Xbox Gamepass + group: PC +- model: games.platform + pk: 4 + fields: + name: Epic Games Store + group: PC +- model: games.platform + pk: 5 + fields: + name: Playstation 5 + group: Playstation +- model: games.platform + pk: 6 + fields: + name: Playstation 4 + group: Playstation +- model: games.platform + pk: 7 + fields: + name: Nintendo Switch + group: Nintendo +- model: games.platform + pk: 8 + fields: + name: Nintendo 3DS + group: Nintendo diff --git a/src/web/tracker/forms.py b/src/timetracker/games/forms.py similarity index 100% rename from src/web/tracker/forms.py rename to src/timetracker/games/forms.py diff --git a/src/web/tracker/migrations/0001_initial.py b/src/timetracker/games/migrations/0001_initial.py similarity index 96% rename from src/web/tracker/migrations/0001_initial.py rename to src/timetracker/games/migrations/0001_initial.py index 36e18b8..2272418 100644 --- a/src/web/tracker/migrations/0001_initial.py +++ b/src/timetracker/games/migrations/0001_initial.py @@ -60,14 +60,14 @@ class Migration(migrations.Migration): ( "game", models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, to="tracker.game" + on_delete=django.db.models.deletion.CASCADE, to="games.game" ), ), ( "platform", models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, - to="tracker.platform", + to="games.platform", ), ), ], @@ -93,7 +93,7 @@ class Migration(migrations.Migration): "purchase", models.ForeignKey( on_delete=django.db.models.deletion.CASCADE, - to="tracker.purchase", + to="games.purchase", ), ), ], diff --git a/src/web/tracker/migrations/0002_alter_session_duration_manual.py b/src/timetracker/games/migrations/0002_alter_session_duration_manual.py similarity index 92% rename from src/web/tracker/migrations/0002_alter_session_duration_manual.py rename to src/timetracker/games/migrations/0002_alter_session_duration_manual.py index 09f15d2..7666aea 100644 --- a/src/web/tracker/migrations/0002_alter_session_duration_manual.py +++ b/src/timetracker/games/migrations/0002_alter_session_duration_manual.py @@ -8,7 +8,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ("tracker", "0001_initial"), + ("games", "0001_initial"), ] operations = [ diff --git a/src/web/tracker/migrations/0003_alter_session_duration_manual_and_more.py b/src/timetracker/games/migrations/0003_alter_session_duration_manual_and_more.py similarity index 90% rename from src/web/tracker/migrations/0003_alter_session_duration_manual_and_more.py rename to src/timetracker/games/migrations/0003_alter_session_duration_manual_and_more.py index 8eeb1b1..04790ea 100644 --- a/src/web/tracker/migrations/0003_alter_session_duration_manual_and_more.py +++ b/src/timetracker/games/migrations/0003_alter_session_duration_manual_and_more.py @@ -6,7 +6,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ("tracker", "0002_alter_session_duration_manual"), + ("games", "0002_alter_session_duration_manual"), ] operations = [ diff --git a/src/web/tracker/migrations/0004_alter_session_duration_manual.py b/src/timetracker/games/migrations/0004_alter_session_duration_manual.py similarity index 86% rename from src/web/tracker/migrations/0004_alter_session_duration_manual.py rename to src/timetracker/games/migrations/0004_alter_session_duration_manual.py index 90e1039..ed11f80 100644 --- a/src/web/tracker/migrations/0004_alter_session_duration_manual.py +++ b/src/timetracker/games/migrations/0004_alter_session_duration_manual.py @@ -8,7 +8,7 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ("tracker", "0003_alter_session_duration_manual_and_more"), + ("games", "0003_alter_session_duration_manual_and_more"), ] operations = [ diff --git a/src/web/tracker/migrations/0005_auto_20230109_1843.py b/src/timetracker/games/migrations/0005_auto_20230109_1843.py similarity index 83% rename from src/web/tracker/migrations/0005_auto_20230109_1843.py rename to src/timetracker/games/migrations/0005_auto_20230109_1843.py index c529636..83ff301 100644 --- a/src/web/tracker/migrations/0005_auto_20230109_1843.py +++ b/src/timetracker/games/migrations/0005_auto_20230109_1843.py @@ -6,7 +6,7 @@ from django.db import migrations def set_duration_calculated_none_to_zero(apps, schema_editor): - Session = apps.get_model("tracker", "Session") + Session = apps.get_model("games", "Session") for session in Session.objects.all(): if session.duration_calculated == None: session.duration_calculated = timedelta(0) @@ -14,7 +14,7 @@ def set_duration_calculated_none_to_zero(apps, schema_editor): def revert_set_duration_calculated_none_to_zero(apps, schema_editor): - Session = apps.get_model("tracker", "Session") + Session = apps.get_model("games", "Session") for session in Session.objects.all(): if session.duration_calculated == timedelta(0): session.duration_calculated = None @@ -24,7 +24,7 @@ def revert_set_duration_calculated_none_to_zero(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ("tracker", "0004_alter_session_duration_manual"), + ("games", "0004_alter_session_duration_manual"), ] operations = [ diff --git a/src/web/tracker/migrations/0006_auto_20230109_1904.py b/src/timetracker/games/migrations/0006_auto_20230109_1904.py similarity index 84% rename from src/web/tracker/migrations/0006_auto_20230109_1904.py rename to src/timetracker/games/migrations/0006_auto_20230109_1904.py index d0a9e04..846d320 100644 --- a/src/web/tracker/migrations/0006_auto_20230109_1904.py +++ b/src/timetracker/games/migrations/0006_auto_20230109_1904.py @@ -6,7 +6,7 @@ from django.db import migrations def set_duration_manual_none_to_zero(apps, schema_editor): - Session = apps.get_model("tracker", "Session") + Session = apps.get_model("games", "Session") for session in Session.objects.all(): if session.duration_manual == None: session.duration_manual = timedelta(0) @@ -14,7 +14,7 @@ def set_duration_manual_none_to_zero(apps, schema_editor): def revert_set_duration_manual_none_to_zero(apps, schema_editor): - Session = apps.get_model("tracker", "Session") + Session = apps.get_model("games", "Session") for session in Session.objects.all(): if session.duration_manual == timedelta(0): session.duration_manual = None @@ -24,7 +24,7 @@ def revert_set_duration_manual_none_to_zero(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ("tracker", "0005_auto_20230109_1843"), + ("games", "0005_auto_20230109_1843"), ] operations = [ diff --git a/src/timetracker/games/migrations/0007_alter_purchase_game_alter_purchase_platform_and_more.py b/src/timetracker/games/migrations/0007_alter_purchase_game_alter_purchase_platform_and_more.py new file mode 100644 index 0000000..77e96a0 --- /dev/null +++ b/src/timetracker/games/migrations/0007_alter_purchase_game_alter_purchase_platform_and_more.py @@ -0,0 +1,35 @@ +# Generated by Django 4.1.5 on 2023-01-19 18:30 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ("games", "0006_auto_20230109_1904"), + ] + + operations = [ + migrations.AlterField( + model_name="purchase", + name="game", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="games.game" + ), + ), + migrations.AlterField( + model_name="purchase", + name="platform", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="games.platform" + ), + ), + migrations.AlterField( + model_name="session", + name="purchase", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="games.purchase" + ), + ), + ] diff --git a/src/web/tracker/__init__.py b/src/timetracker/games/migrations/__init__.py similarity index 100% rename from src/web/tracker/__init__.py rename to src/timetracker/games/migrations/__init__.py diff --git a/src/web/tracker/models.py b/src/timetracker/games/models.py similarity index 98% rename from src/web/tracker/models.py rename to src/timetracker/games/models.py index b469141..d9ac8ae 100644 --- a/src/web/tracker/models.py +++ b/src/timetracker/games/models.py @@ -2,7 +2,7 @@ from datetime import datetime, timedelta from typing import Any from zoneinfo import ZoneInfo -from common.util.time import format_duration +from timetracker.common.util.time import format_duration from django.conf import settings from django.db import models from django.db.models import F, Manager, Sum diff --git a/src/web/tracker/static/base.css b/src/timetracker/games/static/base.css similarity index 100% rename from src/web/tracker/static/base.css rename to src/timetracker/games/static/base.css diff --git a/src/web/tracker/templates/add.html b/src/timetracker/games/templates/add.html similarity index 100% rename from src/web/tracker/templates/add.html rename to src/timetracker/games/templates/add.html diff --git a/src/web/tracker/templates/base.html b/src/timetracker/games/templates/base.html similarity index 100% rename from src/web/tracker/templates/base.html rename to src/timetracker/games/templates/base.html diff --git a/src/web/tracker/templates/index.html b/src/timetracker/games/templates/index.html similarity index 100% rename from src/web/tracker/templates/index.html rename to src/timetracker/games/templates/index.html diff --git a/src/web/tracker/templates/list_sessions.html b/src/timetracker/games/templates/list_sessions.html similarity index 100% rename from src/web/tracker/templates/list_sessions.html rename to src/timetracker/games/templates/list_sessions.html diff --git a/src/web/tracker/templatetags/version.py b/src/timetracker/games/templatetags/version.py similarity index 100% rename from src/web/tracker/templatetags/version.py rename to src/timetracker/games/templatetags/version.py diff --git a/src/web/tracker/tests.py b/src/timetracker/games/tests.py similarity index 100% rename from src/web/tracker/tests.py rename to src/timetracker/games/tests.py diff --git a/src/web/tracker/urls.py b/src/timetracker/games/urls.py similarity index 100% rename from src/web/tracker/urls.py rename to src/timetracker/games/urls.py diff --git a/src/web/tracker/views.py b/src/timetracker/games/views.py similarity index 97% rename from src/web/tracker/views.py rename to src/timetracker/games/views.py index 9274716..aa573f5 100644 --- a/src/web/tracker/views.py +++ b/src/timetracker/games/views.py @@ -21,9 +21,15 @@ def model_counts(request): def add_session(request): context = {} + initial = {} + now = now_with_tz() + initial["timestamp_start"] = now + last = Session.objects.all().last() - initial = {"timestamp_start": now, "purchase": last.purchase} + if last != None: + initial["purchase"] = last.purchase + form = SessionForm(request.POST or None, initial=initial) if form.is_valid(): form.save() diff --git a/src/web/manage.py b/src/timetracker/manage.py similarity index 89% rename from src/web/manage.py rename to src/timetracker/manage.py index ee9f279..a3660b8 100644 --- a/src/web/manage.py +++ b/src/timetracker/manage.py @@ -6,7 +6,7 @@ import sys def main(): """Run administrative tasks.""" - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web.settings") + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "root.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/src/web/tracker/migrations/__init__.py b/src/timetracker/root/__init__.py similarity index 100% rename from src/web/tracker/migrations/__init__.py rename to src/timetracker/root/__init__.py diff --git a/src/web/web/asgi.py b/src/timetracker/root/asgi.py similarity index 75% rename from src/web/web/asgi.py rename to src/timetracker/root/asgi.py index 9c888a0..1ce85f3 100644 --- a/src/web/web/asgi.py +++ b/src/timetracker/root/asgi.py @@ -1,5 +1,5 @@ """ -ASGI config for web project. +ASGI config for root project. It exposes the ASGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ import os from django.core.asgi import get_asgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "root.settings") application = get_asgi_application() diff --git a/src/web/web/settings.py b/src/timetracker/root/settings.py similarity index 95% rename from src/web/web/settings.py rename to src/timetracker/root/settings.py index c0a9f66..470d6a0 100644 --- a/src/web/web/settings.py +++ b/src/timetracker/root/settings.py @@ -1,5 +1,5 @@ """ -Django settings for web project. +Django settings for timetracker project. Generated by 'django-admin startproject' using Django 4.1.4. @@ -32,7 +32,7 @@ ALLOWED_HOSTS = ["*"] # Application definition INSTALLED_APPS = [ - "tracker.apps.TrackerConfig", + "games.apps.GamesConfig", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", @@ -54,7 +54,7 @@ MIDDLEWARE = [ "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = "web.urls" +ROOT_URLCONF = "root.urls" TEMPLATES = [ { @@ -67,13 +67,13 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", - "tracker.views.model_counts", + "games.views.model_counts", ], }, }, ] -WSGI_APPLICATION = "web.wsgi.application" +WSGI_APPLICATION = "root.wsgi.application" # Database diff --git a/src/web/web/urls.py b/src/timetracker/root/urls.py similarity index 92% rename from src/web/web/urls.py rename to src/timetracker/root/urls.py index 029f9a7..8e47b34 100644 --- a/src/web/web/urls.py +++ b/src/timetracker/root/urls.py @@ -1,4 +1,4 @@ -"""web URL Configuration +"""timetracker URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.1/topics/http/urls/ @@ -20,7 +20,7 @@ from django.views.generic import RedirectView urlpatterns = [ path("", RedirectView.as_view(url="/tracker/list-sessions")), - path("tracker/", include("tracker.urls")), + path("tracker/", include("games.urls")), ] if settings.DEBUG: diff --git a/src/web/web/wsgi.py b/src/timetracker/root/wsgi.py similarity index 73% rename from src/web/web/wsgi.py rename to src/timetracker/root/wsgi.py index 8acf062..0b519bb 100644 --- a/src/web/web/wsgi.py +++ b/src/timetracker/root/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for web project. +WSGI config for timetracker project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "root.settings") application = get_wsgi_application() diff --git a/src/web/tracker/fixtures/sample.yaml b/src/web/tracker/fixtures/sample.yaml deleted file mode 100644 index 546ebc1..0000000 --- a/src/web/tracker/fixtures/sample.yaml +++ /dev/null @@ -1,98 +0,0 @@ -- model: tracker.game - pk: 1 - fields: - name: Nioh 2 - wikidata: Q67482292 -- model: tracker.game - pk: 2 - fields: - name: Elden Ring - wikidata: Q64826862 -- model: tracker.game - pk: 3 - fields: - name: Cyberpunk 2077 - wikidata: Q3182559 -- model: tracker.purchase - pk: 1 - fields: - game: 1 - platform: 1 - date_purchased: 2021-02-13 - date_refunded: null -- model: tracker.purchase - pk: 2 - fields: - game: 2 - platform: 1 - date_purchased: 2022-02-24 - date_refunded: null -- model: tracker.purchase - pk: 3 - fields: - game: 3 - platform: 1 - date_purchased: 2020-12-07 - date_refunded: null -- model: tracker.platform - pk: 1 - fields: - name: Steam - group: PC -- model: tracker.platform - pk: 3 - fields: - name: Xbox Gamepass - group: PC -- model: tracker.platform - pk: 4 - fields: - name: Epic Games Store - group: PC -- model: tracker.platform - pk: 5 - fields: - name: Playstation 5 - group: Playstation -- model: tracker.platform - pk: 6 - fields: - name: Playstation 4 - group: Playstation -- model: tracker.platform - pk: 7 - fields: - name: Nintendo Switch - group: Nintendo -- model: tracker.platform - pk: 8 - fields: - name: Nintendo 3DS - group: Nintendo -- model: tracker.session - pk: 1 - fields: - purchase: 2 - timestamp_start: 2022-12-31 14:25:58+00:00 - timestamp_end: 2022-12-31 16:25:22+00:00 - duration_manual: null - duration_calculated: null - note: '' -- model: tracker.session - pk: 3 - fields: - purchase: 3 - timestamp_start: 2023-01-01 22:00:23+00:00 - timestamp_end: 2023-01-01 23:28:23+00:00 - duration_manual: null - duration_calculated: null - note: '' -- model: tracker.session - pk: 4 - fields: - purchase: 3 - timestamp_start: 2020-01-01 23:29:17+00:00 - timestamp_end: 2020-01-01 23:29:17+00:00 - duration_manual: '12:00:00' - duration_calculated: null - note: '' diff --git a/src/web/web/__init__.py b/src/web/web/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_time.py b/tests/test_time.py index 2630401..341a4dc 100644 --- a/tests/test_time.py +++ b/tests/test_time.py @@ -1,7 +1,7 @@ import unittest from datetime import timedelta -from web.common.util.time import format_duration +from timetracker.common.util.time import format_duration class FormatDurationTest(unittest.TestCase):