do multiple update at once

This commit is contained in:
Robert Einsle 2017-04-29 11:38:52 +02:00
parent 9fb04c661d
commit 50823e5688

View File

@ -63,9 +63,11 @@ def accounting_confirm(request, pk):
if 'accountings' in request.POST: if 'accountings' in request.POST:
acc_ids = ast.literal_eval(request.POST['accountings']) acc_ids = ast.literal_eval(request.POST['accountings'])
if len(acc_ids) > 0: if len(acc_ids) > 0:
Accounting.objects.filter(id__in=acc_ids).update(billed=True) Accounting.objects.filter(id__in=acc_ids).update(
Accounting.objects.filter(id__in=acc_ids).update(account_user=request.user.username) billed=True,
Accounting.objects.filter(id__in=acc_ids).update(account_tst=timezone.now()) account_user=request.user.username,
account_tst=timezone.now(),
)
resp = redirect('billard:accounting_detail', pk=pk) resp = redirect('billard:accounting_detail', pk=pk)
return resp return resp