fix code for accounting confirm
This commit is contained in:
parent
cae1ee197e
commit
7ad3a3e22d
@ -1,12 +1,14 @@
|
|||||||
{% extends 'billard/base.html' %}
|
{% extends 'billard/base.html' %}
|
||||||
{% load display_client %}
|
{% load display_client %}
|
||||||
|
|
||||||
{% block title %}Accounting Data{% endblock %}
|
{% block title %}Abrechnung{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="alert alert-success" role="alert">Gesamt-Summe: {{ acc_sum }}</div>
|
<div class="alert alert-success" role="alert">Gesamt-Summe: {{ acc_sum }}</div>
|
||||||
|
|
||||||
|
{{ pk }}
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Start-Datum:</th>
|
<th>Start-Datum:</th>
|
||||||
@ -26,7 +28,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<form action="accounting" method="post" id="accounting">
|
<form action="confirm/" method="post" id="accounting">
|
||||||
{% csrf_token %}
|
{% 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 }}">
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>{% block title %}TITLE SETZEN{% endblock %}</title>
|
<title>carom - {% block title %}TITLE SETZEN{% endblock %}</title>
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<meta name="author" content="">
|
<meta name="author" content="">
|
||||||
{% block header %}
|
{% block header %}
|
||||||
|
@ -14,11 +14,13 @@ urlpatterns = [
|
|||||||
url(r'^(?P<pk>[0-9]+)/$', login_required(views.LocationDetailView.as_view()), name='location_detail'),
|
url(r'^(?P<pk>[0-9]+)/$', login_required(views.LocationDetailView.as_view()), name='location_detail'),
|
||||||
# ex. /billard/1/accounting/
|
# ex. /billard/1/accounting/
|
||||||
url(r'^(?P<pk>[0-9]+)/accounting/$', views.AccountingView.as_view(), name='accounting_detail'),
|
url(r'^(?P<pk>[0-9]+)/accounting/$', views.AccountingView.as_view(), name='accounting_detail'),
|
||||||
|
# ex. /billard/1/accounting/confirm
|
||||||
|
url(r'^(?P<pk>[0-9]+)/accounting/confirm/$', views.accounting_confirm, name='accounting_detail_confirm'),
|
||||||
|
# rest api
|
||||||
|
url(r'api/v1/', include(router.urls)),
|
||||||
|
|
||||||
#url(r'^$', views.index, name='carom_index'),
|
#url(r'^$', views.index, name='carom_index'),
|
||||||
#url(r'^(?P<pk>[0-9]+)/$', views.LocationDataDetailView.as_view(), name='detail'),
|
#url(r'^(?P<pk>[0-9]+)/$', views.LocationDataDetailView.as_view(), name='detail'),
|
||||||
#url(r'api/v1/', include(router.urls)),
|
|
||||||
#url(r'process_locationdata', views.process_locationdata, name='process_locationdata'),
|
#url(r'process_locationdata', views.process_locationdata, name='process_locationdata'),
|
||||||
#url(r'^accounting/$', views.AccountingView.as_view(), name='accounting'),
|
#url(r'^accounting/$', views.AccountingView.as_view(), name='accounting'),
|
||||||
url(r'^accountmodal$', views.accountmodalview, name='accountmodal'),
|
url(r'^accountmodal$', views.accountmodalview, name='accountmodal'),
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import ast
|
||||||
|
|
||||||
from billard.serializers import LocationDataSerializer
|
from billard.serializers import LocationDataSerializer
|
||||||
from billard.models import LocationData, Location, Client, Accounting
|
from billard.models import LocationData, Location, Client, Accounting
|
||||||
from billard.tasks import process_location_data
|
from billard.tasks import process_location_data
|
||||||
@ -39,7 +41,7 @@ class AccountingView(generic.ListView):
|
|||||||
context_object_name = 'accounting'
|
context_object_name = 'accounting'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return Accounting.objects.filter(billed=False).exclude(time_to__isnull=True)
|
return Accounting.objects.filter(billed=False).exclude(time_to__isnull=True).order_by('time_from')
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
result = super(AccountingView, self).dispatch(request, *args, **kwargs)
|
result = super(AccountingView, self).dispatch(request, *args, **kwargs)
|
||||||
@ -52,6 +54,19 @@ class AccountingView(generic.ListView):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@permission_required('billard.change_accounting')
|
||||||
|
def accounting_confirm(request, pk):
|
||||||
|
if request.method == 'POST':
|
||||||
|
if 'accountings' in request.POST:
|
||||||
|
acc_ids = ast.literal_eval(request.POST['accountings'])
|
||||||
|
if len(acc_ids) > 0:
|
||||||
|
Accounting.objects.filter(id__in=acc_ids).update(billed=True)
|
||||||
|
Accounting.objects.filter(id__in=acc_ids).update(account_user=request.user.username)
|
||||||
|
resp = redirect('billard:accounting_detail', pk=pk)
|
||||||
|
return resp
|
||||||
|
|
||||||
|
|
||||||
# TODO OLD CODE, CLEAN UP
|
# TODO OLD CODE, CLEAN UP
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +112,7 @@ def accountmodalconfirmview(request, pk):
|
|||||||
account = Accounting.objects.get(pk=pk)
|
account = Accounting.objects.get(pk=pk)
|
||||||
account.reporter_uuid = None
|
account.reporter_uuid = None
|
||||||
account.save()
|
account.save()
|
||||||
return redirect('carom_index')
|
return redirect('billard:location_detail', pk=pk)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
Loading…
Reference in New Issue
Block a user