2017-01-06 19:11:29 +01:00
|
|
|
from billard.serializers import *
|
2017-01-09 10:59:46 +01:00
|
|
|
from .models import LocationData
|
2017-01-03 19:55:01 +01:00
|
|
|
from rest_framework import viewsets
|
2017-02-01 18:57:29 +01:00
|
|
|
from django.shortcuts import render
|
2017-01-09 10:59:46 +01:00
|
|
|
from django.views import generic
|
2017-01-09 20:42:59 +01:00
|
|
|
from django.views.generic.detail import DetailView
|
2017-02-03 09:42:23 +01:00
|
|
|
from django.contrib.auth.decorators import login_required
|
2017-01-03 19:26:51 +01:00
|
|
|
|
2017-01-03 19:55:01 +01:00
|
|
|
|
|
|
|
class ClientViewSet(viewsets.ModelViewSet):
|
2017-02-01 13:51:15 +01:00
|
|
|
queryset = LocationData.objects.all()
|
2017-01-03 19:55:01 +01:00
|
|
|
serializer_class = ClientSerializer
|
|
|
|
|
|
|
|
|
|
|
|
class LocationViewSet(viewsets.ModelViewSet):
|
2017-02-01 13:51:15 +01:00
|
|
|
queryset = LocationData.objects.all()
|
2017-01-03 19:55:01 +01:00
|
|
|
serializer_class = LocationSerializer
|
|
|
|
|
2017-01-06 18:59:58 +01:00
|
|
|
|
2017-01-03 19:55:01 +01:00
|
|
|
class TableViewSet(viewsets.ModelViewSet):
|
2017-02-01 13:51:15 +01:00
|
|
|
queryset = LocationData.objects.all()
|
2017-01-06 18:59:58 +01:00
|
|
|
serializer_class = TableSerializer
|
2017-01-06 19:11:29 +01:00
|
|
|
|
|
|
|
|
2017-01-06 20:24:36 +01:00
|
|
|
class LocationDataViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = LocationData.objects.all()
|
|
|
|
serializer_class = LocationDataSerializer
|
2017-01-09 10:59:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
class IndexView(generic.ListView):
|
|
|
|
model = LocationData
|
|
|
|
|
2017-01-09 20:42:59 +01:00
|
|
|
|
|
|
|
class LocationDataDetailView(DetailView):
|
|
|
|
model = LocationData
|
2017-02-01 18:57:29 +01:00
|
|
|
|
|
|
|
|
2017-02-03 09:42:23 +01:00
|
|
|
@login_required
|
2017-02-01 18:57:29 +01:00
|
|
|
def index(request):
|
|
|
|
loc = 1
|
|
|
|
if request.POST:
|
|
|
|
loc = request.POST['location-selector']
|
|
|
|
|
|
|
|
locations = Location.objects.order_by('code')
|
|
|
|
clients = Client.objects.filter(location_id=loc).order_by('id')
|
|
|
|
|
|
|
|
context = {
|
|
|
|
'range': range(1, 3),
|
|
|
|
'locations': locations,
|
|
|
|
'clients': clients,
|
|
|
|
'location_id': int(loc),
|
|
|
|
}
|
|
|
|
return render(request, 'billard/index.html', context=context)
|