From 5278634a76c7bdd4e26434c9089d6ce52cc84405 Mon Sep 17 00:00:00 2001 From: Ross Poulton Date: Tue, 19 Apr 2011 21:36:20 +0000 Subject: [PATCH] Fixes GH-54: Stats crash without open tickets. This should have already been caught, so this patch fixes it and adds another sanity check at report runtime. --- helpdesk/templates/helpdesk/report_index.html | 2 +- helpdesk/views/staff.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/helpdesk/templates/helpdesk/report_index.html b/helpdesk/templates/helpdesk/report_index.html index 29bf56de..ac9df4b6 100644 --- a/helpdesk/templates/helpdesk/report_index.html +++ b/helpdesk/templates/helpdesk/report_index.html @@ -3,7 +3,7 @@ {% block helpdesk_title %}{% trans "Reports & Statistics" %}{% endblock %} {% block helpdesk_body %} -{% ifequal num_tickets 0 %}{% blocktrans %} +{% ifequal number_tickets 0 %}{% blocktrans %}

Reports & Statistics

You haven't created any tickets yet, so you cannot run any reports.

diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 79d437b6..a30875d3 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -751,6 +751,8 @@ report_index = staff_member_required(report_index) def run_report(request, report): + if Ticket.objects.all().count() == 0: + return HttpResponseRedirect(reverse("helpdesk_report_index")) priority_sql = [] priority_columns = [] for p in Ticket.PRIORITY_CHOICES: