add location data object
This commit is contained in:
parent
a33cacbe98
commit
ca721ed8b8
@ -32,3 +32,16 @@ class Table(models.Model):
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class TmpLocationData(models.Model):
|
||||
location_id = models.UUIDField(blank=False, null=False)
|
||||
table_no = models.IntegerField(blank=False, null=False)
|
||||
tst = models.DateTimeField(blank=False, null=False)
|
||||
on_off = models.BooleanField(blank=False, null=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
@ -1,4 +1,4 @@
|
||||
from billard.models import Client, Location, Table
|
||||
from billard.models import *
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
@ -18,3 +18,9 @@ class TableSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Table
|
||||
fields = ('client', 'number', 'name',)
|
||||
|
||||
|
||||
class TmpLocationDataSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = TmpLocationData
|
||||
fields = ('location_id', 'table_no', 'tst', 'on_off',)
|
||||
|
@ -6,6 +6,7 @@ router = routers.DefaultRouter()
|
||||
router.register(r'clients', views.ClientViewSet)
|
||||
router.register(r'locations', views.LocationViewSet)
|
||||
router.register(r'tables', views.TableViewSet)
|
||||
router.register(r'data', views.TmpLocationDataViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'api/v1/', include(router.urls)),
|
||||
|
@ -1,5 +1,4 @@
|
||||
from billard.models import Client, Location, Table
|
||||
from billard.serializers import ClientSerializer, LocationSerializer, TableSerializer
|
||||
from billard.serializers import *
|
||||
from rest_framework import viewsets
|
||||
|
||||
|
||||
@ -16,3 +15,8 @@ class LocationViewSet(viewsets.ModelViewSet):
|
||||
class TableViewSet(viewsets.ModelViewSet):
|
||||
queryset = Table.objects.all()
|
||||
serializer_class = TableSerializer
|
||||
|
||||
|
||||
class TmpLocationDataViewSet(viewsets.ModelViewSet):
|
||||
queryset = TmpLocationData.objects.all()
|
||||
serializer_class = TmpLocationDataSerializer
|
||||
|
Loading…
Reference in New Issue
Block a user