Account for no sessions

This commit is contained in:
Lukáš Kucharczyk 2023-11-16 20:29:08 +01:00
parent 4f67bd85c7
commit a32d6c38ab
2 changed files with 9 additions and 1 deletions

View File

@ -23,6 +23,7 @@
</div>
{% endif %}
{% if dataset.count != 0 %}
<table class="responsive-table">
<thead>
<tr>
@ -73,4 +74,7 @@
{% endfor %}
</tbody>
</table>
{% else %}
<div class="mx-auto text-center text-slate-300 text-xl">No sessions found.</div>
{% endif %}
{% endblock content %}

View File

@ -7,6 +7,7 @@ from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect, render
from django.urls import reverse
from django.utils import timezone
from django.core.exceptions import ObjectDoesNotExist
from common.time import format_duration
from common.utils import safe_division
@ -298,7 +299,10 @@ def list_sessions(
context["total_duration"] = dataset.total_duration_formatted()
context["dataset"] = dataset
try:
context["last"] = Session.objects.latest()
except ObjectDoesNotExist:
context["last"] = None
return render(request, "list_sessions.html", context)