rebuild location index and detail view
This commit is contained in:
@@ -8,10 +8,11 @@ from django.views.generic.detail import DetailView
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.db.models import Min, Sum
|
||||
from django.http import HttpResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
|
||||
|
||||
class LocationListView(generic.ListView):
|
||||
template_name = 'billard/location_list.html'
|
||||
class LocationIndexView(generic.ListView):
|
||||
template_name = 'billard/location_index.html'
|
||||
context_object_name = 'location_list'
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -19,13 +20,26 @@ class LocationListView(generic.ListView):
|
||||
return Location.objects.filter(users__id=self.request.user.id).order_by('code')
|
||||
|
||||
|
||||
class LocationDetailView(generic.ListView):
|
||||
template_name = 'billard/location_list.html'
|
||||
context_object_name = 'location_list'
|
||||
class LocationDetailView(generic.DetailView):
|
||||
model = Location
|
||||
template_name = 'billard/location_detail.html'
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if request.is_ajax():
|
||||
context = {
|
||||
'location': self.get_object(),
|
||||
}
|
||||
return render(request, template_name='billard/location_detail_ajax.html', context=context)
|
||||
return super(LocationDetailView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
class AccountingView(generic.ListView):
|
||||
template_name = 'billard/accounting.html'
|
||||
context_object_name = 'accounting'
|
||||
|
||||
def get_queryset(self):
|
||||
"""Return the last five published questions."""
|
||||
return Location.objects.filter(users__id=self.request.user.id).order_by('code')
|
||||
return Accounting.objects.filter(billed=False).exclude(time_to__isnull=True)
|
||||
|
||||
|
||||
# TODO OLD CODE, CLEAN UP
|
||||
@@ -59,7 +73,7 @@ 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
|
||||
# TODO: support multiple account objects
|
||||
except Client.DoesNotExist:
|
||||
account = None
|
||||
context = {
|
||||
@@ -96,7 +110,7 @@ def accounting(request):
|
||||
if loc is None:
|
||||
loc = min_loc
|
||||
locations = Location.objects.filter(users__id=request.user.id).order_by('code')
|
||||
acc = Accounting.objects.filter(billed=False).exclude(time_to__isnull=True).\
|
||||
acc = Accounting.objects.filter(billed=False).exclude(time_to__isnull=True). \
|
||||
filter(desk__client__location_id=loc).order_by('-time_from')
|
||||
acc_sum = acc.aggregate(Sum('prize'))
|
||||
acc_ids = list()
|
||||
@@ -164,18 +178,6 @@ def index(request):
|
||||
return resp
|
||||
|
||||
|
||||
#@login_required
|
||||
#@permission_required('billard.change_accounting')
|
||||
class AccountingView(generic.ListView):
|
||||
template_name = 'billard/accounting.html'
|
||||
context_object_name = 'accounting'
|
||||
|
||||
def get_queryset(self):
|
||||
return Accounting.objects.filter(billed=False).exclude(time_to__isnull=True)\
|
||||
#.\
|
||||
#filter(desk__client__location_id=loc).order_by('-time_from')
|
||||
|
||||
|
||||
def process_locationdata(request):
|
||||
process_location_data()
|
||||
return HttpResponse('DONE')
|
||||
|
||||
Reference in New Issue
Block a user