add checkboxes for accounting

This commit is contained in:
Robert Einsle 2018-02-15 15:58:55 +01:00
parent 7a2fed8ad0
commit 4d0cb78cb6
2 changed files with 23 additions and 22 deletions

View File

@ -15,8 +15,12 @@
{{ pk }} {{ pk }}
<form action="confirm/" method="post" id="accounting">
{% csrf_token %}
<table class="table"> <table class="table">
<tr> <tr>
<th></th>
<th>Start-Datum:</th> <th>Start-Datum:</th>
<th>Stop-Datum:</th> <th>Stop-Datum:</th>
<th>Preis Normal:</th> <th>Preis Normal:</th>
@ -25,6 +29,8 @@
</tr> </tr>
{% for acc in accounting %} {% for acc in accounting %}
<tr> <tr>
<td><input type="checkbox" name="list_acc_id" id="option{{ acc.id }}"
value={{ acc.id }} checked="checked"/></td>
<td>{{ acc.time_from }}</td> <td>{{ acc.time_from }}</td>
<td>{{ acc.time_to }}</td> <td>{{ acc.time_to }}</td>
<td>{{ acc.prize_normal }}</td> <td>{{ acc.prize_normal }}</td>
@ -33,9 +39,6 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
<form action="confirm/" method="post" id="accounting">
{% csrf_token %}
<input type="hidden" name="location-selector" value="{{ location_id }}"> <input type="hidden" name="location-selector" value="{{ location_id }}">
<input type="hidden" name="accountings" value="{{ acc_ids }}"> <input type="hidden" name="accountings" value="{{ acc_ids }}">
<button type="submit" class="btn btn-danger">Abrechnen</button> <button type="submit" class="btn btn-danger">Abrechnen</button>

View File

@ -1,16 +1,14 @@
import ast
import logging import logging
from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.decorators import login_required, permission_required
from django.db.models import Sum from django.db.models import Sum
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.urls import reverse_lazy
from django.utils import timezone from django.utils import timezone
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.views import generic from django.views import generic
from django.views.generic import UpdateView from django.views.generic import UpdateView
from django.urls import reverse_lazy
from rest_framework import viewsets from rest_framework import viewsets
from billard.models import LocationData, Location, Client, Accounting from billard.models import LocationData, Location, Client, Accounting
@ -71,7 +69,7 @@ class AccountingView(generic.ListView):
def accounting_confirm(request, pk): def accounting_confirm(request, pk):
if request.method == 'POST': if request.method == 'POST':
if 'accountings' in request.POST: if 'accountings' in request.POST:
acc_ids = ast.literal_eval(request.POST['accountings']) acc_ids = request.POST.getlist('list_acc_id')
if len(acc_ids) > 0: if len(acc_ids) > 0:
Accounting.objects.filter(id__in=acc_ids).update( Accounting.objects.filter(id__in=acc_ids).update(
billed=True, billed=True,