Major redesign #73

Merged
lukas merged 45 commits from manage-purchases into main 2024-09-02 15:47:44 +00:00
10 changed files with 45 additions and 97 deletions
Showing only changes of commit 2fd44c1f53 - Show all commits

View File

@ -1,154 +1,110 @@
from django.urls import path from django.urls import path
from games import ( from games.views import device, edition, game, general, platform, purchase, session
deviceviews,
editionviews,
gameviews,
platformviews,
purchaseviews,
sessionviews,
views,
)
urlpatterns = [ urlpatterns = [
path("", views.index, name="index"), path("", general.index, name="index"),
path("device/add", deviceviews.add_device, name="add_device"), path("device/add", device.add_device, name="add_device"),
path( path("device/delete/<int:device_id>", device.delete_device, name="delete_device"),
"device/delete/<int:device_id>", deviceviews.delete_device, name="delete_device" path("device/edit/<int:device_id>", device.edit_device, name="edit_device"),
), path("device/list", device.list_devices, name="list_devices"),
path("device/edit/<int:device_id>", deviceviews.edit_device, name="edit_device"), path("edition/add", edition.add_edition, name="add_edition"),
path("device/list", deviceviews.list_devices, name="list_devices"),
path("edition/add", editionviews.add_edition, name="add_edition"),
path( path(
"edition/add/for-game/<int:game_id>", "edition/add/for-game/<int:game_id>",
editionviews.add_edition, edition.add_edition,
name="add_edition_for_game", name="add_edition_for_game",
), ),
path( path("edition/<int:edition_id>/edit", edition.edit_edition, name="edit_edition"),
"edition/<int:edition_id>/edit", editionviews.edit_edition, name="edit_edition" path("edition/list", edition.list_editions, name="list_editions"),
),
path("edition/list", editionviews.list_editions, name="list_editions"),
path( path(
"edition/<int:edition_id>/delete", "edition/<int:edition_id>/delete",
editionviews.delete_edition, edition.delete_edition,
name="delete_edition", name="delete_edition",
), ),
path("game/add", gameviews.add_game, name="add_game"), path("game/add", game.add_game, name="add_game"),
path("game/<int:game_id>/edit", gameviews.edit_game, name="edit_game"), path("game/<int:game_id>/edit", game.edit_game, name="edit_game"),
path("game/<int:game_id>/view", gameviews.view_game, name="view_game"), path("game/<int:game_id>/view", game.view_game, name="view_game"),
path("game/<int:game_id>/delete", gameviews.delete_game, name="delete_game"), path("game/<int:game_id>/delete", game.delete_game, name="delete_game"),
path("game/list", gameviews.list_games, name="list_games"), path("game/list", game.list_games, name="list_games"),
path("platform/add", platformviews.add_platform, name="add_platform"), path("platform/add", platform.add_platform, name="add_platform"),
path( path(
"platform/<int:platform_id>/edit", "platform/<int:platform_id>/edit",
platformviews.edit_platform, platform.edit_platform,
name="edit_platform", name="edit_platform",
), ),
path( path(
"platform/<int:platform_id>/delete", "platform/<int:platform_id>/delete",
platformviews.delete_platform, platform.delete_platform,
name="delete_platform", name="delete_platform",
), ),
path("platform/list", platformviews.list_platforms, name="list_platforms"), path("platform/list", platform.list_platforms, name="list_platforms"),
path("purchase/add", purchaseviews.add_purchase, name="add_purchase"), path("purchase/add", purchase.add_purchase, name="add_purchase"),
path( path(
"purchase/<int:purchase_id>/edit", "purchase/<int:purchase_id>/edit",
purchaseviews.edit_purchase, purchase.edit_purchase,
name="edit_purchase", name="edit_purchase",
), ),
path( path(
"purchase/<int:purchase_id>/delete", "purchase/<int:purchase_id>/delete",
purchaseviews.delete_purchase, purchase.delete_purchase,
name="delete_purchase", name="delete_purchase",
), ),
path( path(
"purchase/list", "purchase/list",
purchaseviews.list_purchases, purchase.list_purchases,
name="list_purchases", name="list_purchases",
), ),
path( path(
"purchase/related-purchase-by-edition", "purchase/related-purchase-by-edition",
purchaseviews.related_purchase_by_edition, purchase.related_purchase_by_edition,
name="related_purchase_by_edition", name="related_purchase_by_edition",
), ),
path( path(
"purchase/add/for-edition/<int:edition_id>", "purchase/add/for-edition/<int:edition_id>",
purchaseviews.add_purchase, purchase.add_purchase,
name="add_purchase_for_edition", name="add_purchase_for_edition",
), ),
path("session/add", sessionviews.add_session, name="add_session"), path("session/add", session.add_session, name="add_session"),
path( path(
"session/add/for-purchase/<int:purchase_id>", "session/add/for-purchase/<int:purchase_id>",
sessionviews.add_session, session.add_session,
name="add_session_for_purchase", name="add_session_for_purchase",
), ),
path( path(
"session/add/from-game/<int:session_id>", "session/add/from-game/<int:session_id>",
sessionviews.new_session_from_existing_session, session.new_session_from_existing_session,
{"template": "view_game.html#session-info"}, {"template": "view_game.html#session-info"},
name="view_game_start_session_from_session", name="view_game_start_session_from_session",
), ),
path( path(
"session/add/from-list/<int:session_id>", "session/add/from-list/<int:session_id>",
sessionviews.new_session_from_existing_session, session.new_session_from_existing_session,
{"template": "list_sessions.html#session-row"}, {"template": "list_sessions.html#session-row"},
name="list_sessions_start_session_from_session", name="list_sessions_start_session_from_session",
), ),
path( path("session/<int:session_id>/edit", session.edit_session, name="edit_session"),
"session/<int:session_id>/edit", sessionviews.edit_session, name="edit_session"
),
path( path(
"session/<int:session_id>/delete", "session/<int:session_id>/delete",
sessionviews.delete_session, session.delete_session,
name="delete_session", name="delete_session",
), ),
path( path(
"session/end/from-game/<int:session_id>", "session/end/from-game/<int:session_id>",
sessionviews.end_session, session.end_session,
{"template": "view_game.html#session-info"}, {"template": "view_game.html#session-info"},
name="view_game_end_session", name="view_game_end_session",
), ),
path( path(
"session/end/from-list/<int:session_id>", "session/end/from-list/<int:session_id>",
sessionviews.end_session, session.end_session,
{"template": "list_sessions.html#session-row"}, {"template": "list_sessions.html#session-row"},
name="list_sessions_end_session", name="list_sessions_end_session",
), ),
path("session/list", sessionviews.list_sessions, name="list_sessions"), path("session/list", session.list_sessions, name="list_sessions"),
path( path("stats/", general.stats_alltime, name="stats_alltime"),
"session/list/by-purchase/<int:purchase_id>",
sessionviews.list_sessions,
{"filter": "purchase"},
name="list_sessions_by_purchase",
),
path(
"session/list/by-platform/<int:platform_id>",
sessionviews.list_sessions,
{"filter": "platform"},
name="list_sessions_by_platform",
),
path(
"session/list/by-game/<int:game_id>",
sessionviews.list_sessions,
{"filter": "game"},
name="list_sessions_by_game",
),
path(
"session/list/by-edition/<int:edition_id>",
sessionviews.list_sessions,
{"filter": "edition"},
name="list_sessions_by_edition",
),
path(
"session/list/by-ownership/<str:ownership_type>",
sessionviews.list_sessions,
{"filter": "ownership_type"},
name="list_sessions_by_ownership_type",
),
path("stats/", views.stats_alltime, name="stats_alltime"),
path( path(
"stats/<int:year>", "stats/<int:year>",
views.stats, general.stats,
name="stats_by_year", name="stats_by_year",
), ),
] ]

0
games/views/__init__.py Normal file
View File

View File

@ -9,7 +9,7 @@ from django.urls import reverse
from games.forms import DeviceForm from games.forms import DeviceForm
from games.models import Device from games.models import Device
from games.views import dateformat from games.views.general import dateformat
@login_required @login_required

View File

@ -10,7 +10,7 @@ from django.urls import reverse
from common.utils import truncate_with_popover from common.utils import truncate_with_popover
from games.forms import EditionForm from games.forms import EditionForm
from games.models import Edition, Game from games.models import Edition, Game
from games.views import dateformat from games.views.general import dateformat
@login_required @login_required

View File

@ -11,7 +11,7 @@ from common.time import format_duration
from common.utils import safe_division, safe_getattr, truncate_with_popover from common.utils import safe_division, safe_getattr, truncate_with_popover
from games.forms import GameForm from games.forms import GameForm
from games.models import Game, Purchase, Session from games.models import Game, Purchase, Session
from games.views import dateformat, use_custom_redirect from games.views.general import dateformat, use_custom_redirect
@login_required @login_required

View File

@ -7,12 +7,10 @@ from django.db.models.manager import BaseManager
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect, render from django.shortcuts import redirect, render
from django.urls import reverse from django.urls import reverse
from django.utils import timezone
from common.time import format_duration from common.time import format_duration
from common.utils import safe_division from common.utils import safe_division
from games.models import Edition, Game, Platform, Purchase, Session
from .models import Edition, Game, Platform, Purchase, Session
dateformat: str = "%d/%m/%Y" dateformat: str = "%d/%m/%Y"
datetimeformat: str = "%d/%m/%Y %H:%M" datetimeformat: str = "%d/%m/%Y %H:%M"
@ -31,11 +29,6 @@ def model_counts(request: HttpRequest) -> dict[str, bool]:
} }
def stats_dropdown_year_range(request: HttpRequest) -> dict[str, range]:
result = {"stats_dropdown_year_range": range(timezone.now().year, 1999, -1)}
return result
def use_custom_redirect( def use_custom_redirect(
func: Callable[..., HttpResponse], func: Callable[..., HttpResponse],
) -> Callable[..., HttpResponse]: ) -> Callable[..., HttpResponse]:

View File

@ -9,7 +9,7 @@ from django.urls import reverse
from games.forms import PlatformForm from games.forms import PlatformForm
from games.models import Platform from games.models import Platform
from games.views import dateformat, use_custom_redirect from games.views.general import dateformat, use_custom_redirect
@login_required @login_required

View File

@ -16,7 +16,7 @@ from django.utils import timezone
from common.utils import truncate_with_popover from common.utils import truncate_with_popover
from games.forms import PurchaseForm from games.forms import PurchaseForm
from games.models import Edition, Purchase from games.models import Edition, Purchase
from games.views import dateformat, use_custom_redirect from games.views.general import dateformat, use_custom_redirect
@login_required @login_required

View File

@ -12,7 +12,7 @@ from common.time import format_duration
from common.utils import truncate_with_popover from common.utils import truncate_with_popover
from games.forms import SessionForm from games.forms import SessionForm
from games.models import Purchase, Session from games.models import Purchase, Session
from games.views import ( from games.views.general import (
dateformat, dateformat,
datetimeformat, datetimeformat,
durationformat, durationformat,

View File

@ -83,8 +83,7 @@ TEMPLATES = [
"django.template.context_processors.request", "django.template.context_processors.request",
"django.contrib.auth.context_processors.auth", "django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages", "django.contrib.messages.context_processors.messages",
"games.views.model_counts", "games.views.general.model_counts",
"games.views.stats_dropdown_year_range",
], ],
"builtins": [ "builtins": [
"template_partials.templatetags.partials", "template_partials.templatetags.partials",