linkify game, edition, purchase, session references
Some checks failed
Django CI/CD / test (push) Successful in 1m0s
Django CI/CD / build-and-push (push) Has been cancelled

also add link styles for links in a table row
This commit is contained in:
2024-09-02 20:04:21 +02:00
parent b8258e2937
commit e067e65bce
7 changed files with 174 additions and 85 deletions

View File

@ -7,7 +7,7 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.template.loader import render_to_string
from django.urls import reverse
from common.utils import truncate_with_popover
from common.utils import A, truncate_with_popover
from games.forms import EditionForm
from games.models import Edition, Game
from games.views.general import dateformat
@ -48,7 +48,18 @@ def list_editions(request: HttpRequest) -> HttpResponse:
],
"rows": [
[
truncate_with_popover(edition.game.name),
A(
[
(
"href",
reverse(
"view_game",
args=[edition.game.pk],
),
)
],
truncate_with_popover(edition.game.name),
),
truncate_with_popover(
edition.name
if edition.game.name != edition.name

View File

@ -9,7 +9,7 @@ from django.template.loader import render_to_string
from django.urls import reverse
from common.time import format_duration
from common.utils import safe_division, truncate_with_popover
from common.utils import A, safe_division, truncate_with_popover
from games.forms import GameForm
from games.models import Edition, Game, Purchase, Session
from games.views.general import (
@ -55,7 +55,18 @@ def list_games(request: HttpRequest) -> HttpResponse:
],
"rows": [
[
truncate_with_popover(game.name),
A(
[
(
"href",
reverse(
"view_game",
args=[game.pk],
),
)
],
truncate_with_popover(game.name),
),
truncate_with_popover(
game.sort_name
if game.sort_name is not None and game.name != game.sort_name

View File

@ -13,7 +13,7 @@ from django.template.loader import render_to_string
from django.urls import reverse
from django.utils import timezone
from common.utils import truncate_with_popover
from common.utils import A, truncate_with_popover
from games.forms import PurchaseForm
from games.models import Edition, Purchase
from games.views.general import dateformat, use_custom_redirect
@ -57,7 +57,18 @@ def list_purchases(request: HttpRequest) -> HttpResponse:
],
"rows": [
[
truncate_with_popover(purchase.edition.name),
A(
[
(
"href",
reverse(
"view_game",
args=[purchase.edition.game.pk],
),
),
],
truncate_with_popover(purchase.edition.game.name),
),
purchase.platform,
purchase.price,
purchase.price_currency,

View File

@ -9,7 +9,7 @@ from django.urls import reverse
from django.utils import timezone
from common.time import format_duration
from common.utils import truncate_with_popover
from common.utils import A, truncate_with_popover
from games.forms import SessionForm
from games.models import Purchase, Session
from games.views.general import (
@ -56,7 +56,18 @@ def list_sessions(request: HttpRequest) -> HttpResponse:
],
"rows": [
[
truncate_with_popover(session.purchase.edition.name),
A(
[
(
"href",
reverse(
"view_game",
args=[session.purchase.edition.game.pk],
),
)
],
truncate_with_popover(session.purchase.edition.name),
),
f"{session.timestamp_start.strftime(datetimeformat)}{f"{session.timestamp_end.strftime(timeformat)}" if session.timestamp_end else ""}",
(
format_duration(session.duration_calculated, durationformat)