Compare commits
No commits in common. "a84209eb81d5b0881743eda15fd807acdd2cb348" and "b28c42d9452c0c5ad9b157db2c95da1d9914fbdd" have entirely different histories.
a84209eb81
...
b28c42d945
|
@ -7,7 +7,6 @@ from django.shortcuts import render
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from common.utils import truncate_with_popover
|
|
||||||
from games.models import Game
|
from games.models import Game
|
||||||
from games.views import dateformat
|
from games.views import dateformat
|
||||||
|
|
||||||
|
@ -45,12 +44,8 @@ def list_games(request: HttpRequest) -> HttpResponse:
|
||||||
],
|
],
|
||||||
"rows": [
|
"rows": [
|
||||||
[
|
[
|
||||||
truncate_with_popover(game.name),
|
game.name,
|
||||||
truncate_with_popover(
|
game.sort_name,
|
||||||
game.sort_name
|
|
||||||
if game.sort_name is not None and game.name != game.sort_name
|
|
||||||
else "(identical)"
|
|
||||||
),
|
|
||||||
game.year_released,
|
game.year_released,
|
||||||
game.wikidata,
|
game.wikidata,
|
||||||
game.created_at.strftime(dateformat),
|
game.created_at.strftime(dateformat),
|
||||||
|
|
|
@ -2,12 +2,12 @@ from typing import Any
|
||||||
|
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
|
from django.db.models.manager import BaseManager
|
||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from common.utils import truncate_with_popover
|
|
||||||
from games.models import Purchase
|
from games.models import Purchase
|
||||||
from games.views import dateformat
|
from games.views import dateformat
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ def list_purchases(request: HttpRequest) -> HttpResponse:
|
||||||
],
|
],
|
||||||
"rows": [
|
"rows": [
|
||||||
[
|
[
|
||||||
truncate_with_popover(purchase.edition.name),
|
purchase.edition.name,
|
||||||
purchase.platform,
|
purchase.platform,
|
||||||
purchase.price,
|
purchase.price,
|
||||||
purchase.price_currency,
|
purchase.price_currency,
|
||||||
|
|
|
@ -8,15 +8,8 @@ from django.template.loader import render_to_string
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from common.time import format_duration
|
from common.time import format_duration
|
||||||
from common.utils import truncate_with_popover
|
|
||||||
from games.models import Session
|
from games.models import Session
|
||||||
from games.views import (
|
from games.views import dateformat, datetimeformat, timeformat
|
||||||
dateformat,
|
|
||||||
datetimeformat,
|
|
||||||
durationformat,
|
|
||||||
durationformat_manual,
|
|
||||||
timeformat,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -24,7 +17,7 @@ def list_sessions(request: HttpRequest) -> HttpResponse:
|
||||||
context: dict[Any, Any] = {}
|
context: dict[Any, Any] = {}
|
||||||
page_number = request.GET.get("page", 1)
|
page_number = request.GET.get("page", 1)
|
||||||
limit = request.GET.get("limit", 10)
|
limit = request.GET.get("limit", 10)
|
||||||
sessions = Session.objects.order_by("-timestamp_start")
|
sessions = Session.objects.order_by("-created_at")
|
||||||
page_obj = None
|
page_obj = None
|
||||||
if int(limit) != 0:
|
if int(limit) != 0:
|
||||||
paginator = Paginator(sessions, limit)
|
paginator = Paginator(sessions, limit)
|
||||||
|
@ -53,15 +46,15 @@ def list_sessions(request: HttpRequest) -> HttpResponse:
|
||||||
],
|
],
|
||||||
"rows": [
|
"rows": [
|
||||||
[
|
[
|
||||||
truncate_with_popover(session.purchase.edition.name),
|
session.purchase.edition.name,
|
||||||
f"{session.timestamp_start.strftime(datetimeformat)}{f" — {session.timestamp_end.strftime(timeformat)}" if session.timestamp_end else ""}",
|
f"{session.timestamp_start.strftime(datetimeformat)}{f" — {session.timestamp_end.strftime(timeformat)}" if session.timestamp_end else ""}",
|
||||||
(
|
(
|
||||||
format_duration(session.duration_calculated, durationformat)
|
format_duration(session.duration_calculated, "%2.1H hours")
|
||||||
if session.duration_calculated
|
if session.duration_calculated
|
||||||
else "-"
|
else "-"
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
format_duration(session.duration_manual, durationformat_manual)
|
format_duration(session.duration_manual)
|
||||||
if session.duration_manual
|
if session.duration_manual
|
||||||
else "-"
|
else "-"
|
||||||
),
|
),
|
||||||
|
|
|
@ -29,9 +29,7 @@ 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"
|
||||||
timeformat: str = "%H:%M"
|
timeformat = "%H:%M"
|
||||||
durationformat: str = "%2.1H hours"
|
|
||||||
durationformat_manual: str = "%H hours"
|
|
||||||
|
|
||||||
|
|
||||||
def model_counts(request: HttpRequest) -> dict[str, bool]:
|
def model_counts(request: HttpRequest) -> dict[str, bool]:
|
||||||
|
|
Loading…
Reference in New Issue