Account for no sessions
Django CI/CD / build-and-push (push) Successful in 1m21s Details

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

View File

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

View File

@ -7,6 +7,7 @@ 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 django.utils import timezone
from django.core.exceptions import ObjectDoesNotExist
from common.time import format_duration from common.time import format_duration
from common.utils import safe_division from common.utils import safe_division
@ -298,7 +299,10 @@ def list_sessions(
context["total_duration"] = dataset.total_duration_formatted() context["total_duration"] = dataset.total_duration_formatted()
context["dataset"] = dataset context["dataset"] = dataset
context["last"] = Session.objects.latest() try:
context["last"] = Session.objects.latest()
except ObjectDoesNotExist:
context["last"] = None
return render(request, "list_sessions.html", context) return render(request, "list_sessions.html", context)