diff --git a/billard/templates/billard/accounting.html b/billard/templates/billard/accounting.html
index 112beae..b6dedd1 100644
--- a/billard/templates/billard/accounting.html
+++ b/billard/templates/billard/accounting.html
@@ -4,18 +4,6 @@
{% block title %}Accounting Data{% endblock %}
{% block content %}
-{% if not locations|length_is:"1" %}
-
-{% endif %}
Gesamt-Summe: {{ acc_sum }}
diff --git a/billard/templates/billard/base.html b/billard/templates/billard/base.html
index 4b084df..dded387 100644
--- a/billard/templates/billard/base.html
+++ b/billard/templates/billard/base.html
@@ -29,9 +29,6 @@
- Standorte
-{% if perms.billard.change_accounting %}
- - Abrechnung
-{% endif %}
{% if user.is_superuser %}
- Administration
{% endif %}
diff --git a/billard/templates/billard/location_index.html b/billard/templates/billard/location_index.html
index 2816b8b..196b36f 100644
--- a/billard/templates/billard/location_index.html
+++ b/billard/templates/billard/location_index.html
@@ -13,6 +13,9 @@
Strasse |
Plz |
Ort |
+{% if perms.billard.change_accounting %}
+ Accounting |
+{% endif %}
{% for loc in location_list %}
@@ -21,6 +24,9 @@
{{ loc.street|default_if_none:"" }} |
{{ loc.plz|default_if_none:"" }} |
{{ loc.city|default_if_none:"" }} |
+{% if perms.billard.change_accounting %}
+ Abrechnen |
+{% endif %}
{% endfor %}
diff --git a/billard/urls.py b/billard/urls.py
index 4a71067..13616de 100644
--- a/billard/urls.py
+++ b/billard/urls.py
@@ -13,7 +13,7 @@ urlpatterns = [
# ex. /billard/1/
url(r'^(?P[0-9]+)/$', login_required(views.LocationDetailView.as_view()), name='location_detail'),
# ex. /billard/1/accounting/
- #url(r'^(?P[0-9]+)/accounting/$', views.ResultsView.as_view(), name='accounting_detail'),
+ url(r'^(?P[0-9]+)/accounting/$', views.AccountingView.as_view(), name='accounting_detail'),
#url(r'^$', views.index, name='carom_index'),
diff --git a/billard/views.py b/billard/views.py
index 6a89687..8c15f71 100644
--- a/billard/views.py
+++ b/billard/views.py
@@ -41,6 +41,16 @@ class AccountingView(generic.ListView):
def get_queryset(self):
return Accounting.objects.filter(billed=False).exclude(time_to__isnull=True)
+ def dispatch(self, request, *args, **kwargs):
+ result = super(AccountingView, self).dispatch(request, *args, **kwargs)
+ acc_sum = self.get_queryset().aggregate(Sum('prize'))
+ if acc_sum['prize__sum'] is None:
+ result.context_data['acc_sum'] = 0
+ else:
+ result.context_data['acc_sum'] = acc_sum['prize__sum']
+ result.context_data['acc_ids'] = [acc.id for acc in self.get_queryset().all()]
+ return result
+
# TODO OLD CODE, CLEAN UP