fix code for accounting modal view
This commit is contained in:
parent
7ad3a3e22d
commit
f0ed2a5195
@ -22,7 +22,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a class="btn btn-default btn-primary" href="{% url 'accountmodalconfirm' account.pk %}">Schliessen</a>
|
<a class="btn btn-default btn-primary" href="{% url 'billard:account_modal_confirm' pk=account.id %}">Schliessen</a>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /.modal-content -->
|
</div><!-- /.modal-content -->
|
||||||
</div><!-- /.modal-dialog -->
|
</div><!-- /.modal-dialog -->
|
||||||
|
@ -20,6 +20,12 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
function refresh_page() {
|
function refresh_page() {
|
||||||
$('#desk_data').load('#');
|
$('#desk_data').load('#');
|
||||||
|
$('#modal-wrapper').load('{% url 'billard:account_modal' %}', function() {
|
||||||
|
if ( $('#accountsmodal').length ) {
|
||||||
|
window.clearInterval(interval);
|
||||||
|
$('#accountsmodal').modal('show');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -16,6 +16,10 @@ urlpatterns = [
|
|||||||
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
|
# ex. /billard/1/accounting/confirm
|
||||||
url(r'^(?P<pk>[0-9]+)/accounting/confirm/$', views.accounting_confirm, name='accounting_detail_confirm'),
|
url(r'^(?P<pk>[0-9]+)/accounting/confirm/$', views.accounting_confirm, name='accounting_detail_confirm'),
|
||||||
|
# ex. /billard/1/account_modal/
|
||||||
|
url(r'^account_modal/$', views.account_modal_view, name='account_modal'),
|
||||||
|
# ex. /billard/1/account_modal/confirm/
|
||||||
|
url(r'^account_modal/(?P<pk>[0-9]+)/confirm/$', views.account_modal_confirm_view, name='account_modal_confirm'),
|
||||||
# rest api
|
# rest api
|
||||||
url(r'api/v1/', include(router.urls)),
|
url(r'api/v1/', include(router.urls)),
|
||||||
|
|
||||||
@ -23,7 +27,7 @@ urlpatterns = [
|
|||||||
#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'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'),
|
||||||
url(r'^accoutmodal/confirm/(?P<pk>[0-9]+)$', views.accountmodalconfirmview, name="accountmodalconfirm")
|
#url(r'^accoutmodal/confirm/(?P<pk>[0-9]+)$', views.accountmodalconfirmview, name="accountmodalconfirm")
|
||||||
# (?P<pk>[0-9]+)
|
# (?P<pk>[0-9]+)
|
||||||
]
|
]
|
||||||
|
@ -67,6 +67,28 @@ def accounting_confirm(request, pk):
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def account_modal_view(request):
|
||||||
|
try:
|
||||||
|
uuids = Client.objects.filter(report_user=request.user).values_list('uuid')
|
||||||
|
account = Accounting.objects.filter(reporter_uuid__in=uuids).first
|
||||||
|
# TODO: support multiple account objects
|
||||||
|
except Client.DoesNotExist:
|
||||||
|
account = None
|
||||||
|
context = {
|
||||||
|
'account': account
|
||||||
|
}
|
||||||
|
return render(request, 'billard/accountmodal.html', context=context)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def account_modal_confirm_view(request, pk):
|
||||||
|
account = Accounting.objects.get(pk=pk)
|
||||||
|
account.reporter_uuid = None
|
||||||
|
account.save()
|
||||||
|
return redirect('billard:location_detail', pk=account.desk.client.location_id)
|
||||||
|
|
||||||
|
|
||||||
# TODO OLD CODE, CLEAN UP
|
# TODO OLD CODE, CLEAN UP
|
||||||
|
|
||||||
|
|
||||||
@ -93,26 +115,6 @@ class LocationDataDetailView(DetailView):
|
|||||||
return super().get_template_names()
|
return super().get_template_names()
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
def accountmodalview(request):
|
|
||||||
try:
|
|
||||||
uuids = Client.objects.filter(report_user=request.user).values_list('uuid')
|
|
||||||
account = Accounting.objects.filter(reporter_uuid__in=uuids).first
|
|
||||||
# TODO: support multiple account objects
|
|
||||||
except Client.DoesNotExist:
|
|
||||||
account = None
|
|
||||||
context = {
|
|
||||||
'account': account
|
|
||||||
}
|
|
||||||
return render(request, 'billard/accountmodal.html', context=context)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
def accountmodalconfirmview(request, pk):
|
|
||||||
account = Accounting.objects.get(pk=pk)
|
|
||||||
account.reporter_uuid = None
|
|
||||||
account.save()
|
|
||||||
return redirect('billard:location_detail', pk=pk)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
Loading…
Reference in New Issue
Block a user