update accounting dialog
This commit is contained in:
		@@ -4,18 +4,6 @@
 | 
			
		||||
{% block title %}Accounting Data{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
{% if not locations|length_is:"1" %}
 | 
			
		||||
    <form action="accounting" method="post" id="location-form">
 | 
			
		||||
{% csrf_token %}
 | 
			
		||||
        <div id="location-selector" class="alert">
 | 
			
		||||
            <select class="form-control" form="location-form" name="location-selector" id="location-select">
 | 
			
		||||
{% for loc in locations %}
 | 
			
		||||
                <option value="{{ loc.id }}"{%  if loc.id == location_id %} selected{% endif %}>{{ loc.code }} - {{ loc.name }}</option>
 | 
			
		||||
{% endfor %}
 | 
			
		||||
            </select>
 | 
			
		||||
        </div>
 | 
			
		||||
    </form>
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
    <div class="alert alert-success" role="alert">Gesamt-Summe: {{ acc_sum }}</div>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -29,9 +29,6 @@
 | 
			
		||||
            <div id="navbar" class="collapse navbar-collapse">
 | 
			
		||||
                <ul class="nav navbar-nav">
 | 
			
		||||
                    <li class="{% ifequal request.path '/billard/' %}active{% endifequal %}"><a href="{% url "billard:location_index" %}">Standorte</a></li>
 | 
			
		||||
{% if perms.billard.change_accounting %}
 | 
			
		||||
                    <li class="{% ifequal request.path '/billard/accounting' %}active{% endifequal %}"><a href="{% url "billard:location_index" %}">Abrechnung</a></li>
 | 
			
		||||
{% endif %}
 | 
			
		||||
{% if user.is_superuser %}
 | 
			
		||||
                    <li class="{% ifequal request.path '/logout/' %}active{% endifequal %}"><a href="/admin/">Administration</a></li>
 | 
			
		||||
{% endif %}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,9 @@
 | 
			
		||||
            <th>Strasse</th>
 | 
			
		||||
            <th>Plz</th>
 | 
			
		||||
            <th>Ort</th>
 | 
			
		||||
{% if perms.billard.change_accounting %}
 | 
			
		||||
            <th>Accounting</th>
 | 
			
		||||
{% endif %}
 | 
			
		||||
        </tr>
 | 
			
		||||
{% for loc in location_list %}
 | 
			
		||||
        <tr>
 | 
			
		||||
@@ -21,6 +24,9 @@
 | 
			
		||||
            <td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.street|default_if_none:"" }}</a></td>
 | 
			
		||||
            <td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.plz|default_if_none:"" }}</a></td>
 | 
			
		||||
            <td><a href="{% url 'billard:location_detail' loc.id %}">{{ loc.city|default_if_none:"" }}</a></td>
 | 
			
		||||
{% if perms.billard.change_accounting %}
 | 
			
		||||
            <td><a href="{% url 'billard:accounting_detail' loc.id %}" class="btn btn-primary">Abrechnen</a></td>
 | 
			
		||||
{% endif %}
 | 
			
		||||
        </tr>
 | 
			
		||||
{% endfor %}
 | 
			
		||||
    </table>
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ urlpatterns = [
 | 
			
		||||
    # ex. /billard/1/
 | 
			
		||||
    url(r'^(?P<pk>[0-9]+)/$', login_required(views.LocationDetailView.as_view()), name='location_detail'),
 | 
			
		||||
    # ex. /billard/1/accounting/
 | 
			
		||||
    #url(r'^(?P<pk>[0-9]+)/accounting/$', views.ResultsView.as_view(), name='accounting_detail'),
 | 
			
		||||
    url(r'^(?P<pk>[0-9]+)/accounting/$', views.AccountingView.as_view(), name='accounting_detail'),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    #url(r'^$', views.index, name='carom_index'),
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user