Add vite react #45
|
@ -22,9 +22,7 @@
|
||||||
<nav class="mb-4 bg-white dark:bg-gray-900 border-gray-200 rounded">
|
<nav class="mb-4 bg-white dark:bg-gray-900 border-gray-200 rounded">
|
||||||
<div class="container flex flex-wrap items-center justify-between mx-auto">
|
<div class="container flex flex-wrap items-center justify-between mx-auto">
|
||||||
<a href="{% url 'list_sessions_recent' %}" class="flex items-center">
|
<a href="{% url 'list_sessions_recent' %}" class="flex items-center">
|
||||||
<span class="text-4xl">
|
<span class="text-4xl">⌚</span>
|
||||||
<img src="{% static 'icons/schedule.png' %}" width="48" class="mr-4" />
|
|
||||||
</span>
|
|
||||||
<span class="self-center text-xl font-semibold whitespace-nowrap text-white">Timetracker</span>
|
<span class="self-center text-xl font-semibold whitespace-nowrap text-white">Timetracker</span>
|
||||||
</a>
|
</a>
|
||||||
<div class="w-full md:block md:w-auto">
|
<div class="w-full md:block md:w-auto">
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
{% load static %}
|
|
||||||
{% block title %}
|
{% block title %}{{ title }}{% endblock title %}
|
||||||
{{ title }}
|
|
||||||
{% endblock title %}
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if dataset.count >= 1 %}
|
{% if dataset.count >= 1 %}
|
||||||
<div class="mx-auto text-center my-4">
|
<div class="mx-auto text-center my-4">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Any, Callable
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.db.models import Count, F, Prefetch, Sum
|
from django.db.models import Count, F, Prefetch, Sum
|
||||||
|
@ -283,16 +283,11 @@ def list_sessions(
|
||||||
elif filter == "game":
|
elif filter == "game":
|
||||||
dataset = Session.objects.filter(purchase__edition__game=game_id)
|
dataset = Session.objects.filter(purchase__edition__game=game_id)
|
||||||
context["game"] = Game.objects.get(id=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":
|
elif filter == "recent":
|
||||||
current_year = timezone.now().year
|
|
||||||
first_day_of_year = timezone.make_aware(datetime(current_year, 1, 1))
|
|
||||||
dataset = Session.objects.filter(
|
dataset = Session.objects.filter(
|
||||||
timestamp_start__gte=first_day_of_year
|
timestamp_start__gte=datetime.now() - timedelta(days=30)
|
||||||
).order_by("-timestamp_start")
|
)
|
||||||
context["title"] = "This year"
|
context["title"] = "Last 30 days"
|
||||||
else:
|
else:
|
||||||
# by default, sort from newest to oldest
|
# by default, sort from newest to oldest
|
||||||
dataset = Session.objects.order_by("-timestamp_start")
|
dataset = Session.objects.order_by("-timestamp_start")
|
||||||
|
@ -547,19 +542,3 @@ def add_platform(request):
|
||||||
context["form"] = form
|
context["form"] = form
|
||||||
context["title"] = "Add New Platform"
|
context["title"] = "Add New Platform"
|
||||||
return render(request, "add.html", context)
|
return render(request, "add.html", context)
|
||||||
|
|
||||||
|
|
||||||
def add_device(request):
|
|
||||||
context = {}
|
|
||||||
form = DeviceForm(request.POST or None)
|
|
||||||
if form.is_valid():
|
|
||||||
form.save()
|
|
||||||
return redirect("index")
|
|
||||||
|
|
||||||
context["form"] = form
|
|
||||||
context["title"] = "Add New Device"
|
|
||||||
return render(request, "add.html", context)
|
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
|
||||||
return redirect("list_sessions_recent")
|
|
||||||
|
|
|
@ -73,8 +73,8 @@ router.register(r"sessions", SessionViewSet)
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("api/", include(router.urls)),
|
path("", RedirectView.as_view(url="/tracker")),
|
||||||
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
|
path("tracker/", include("games.urls")),
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|
Loading…
Reference in New Issue