Merge branch 'develop' of ssh://git.einsle.de:5000/carom/carom-server into develop
This commit is contained in:
19
billard/serializers.py
Normal file
19
billard/serializers.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from billard.models import Client, Location, Table
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class ClientSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Client
|
||||
fields = ('id', 'location')
|
||||
|
||||
|
||||
class LocationSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Location
|
||||
fields = ('name')
|
||||
|
||||
class TableSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Table
|
||||
fields = ('client', 'number', 'name')
|
12
billard/urls.py
Normal file
12
billard/urls.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from django.conf.urls import url, include
|
||||
from rest_framework import routers
|
||||
from billard import views
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'clients', views.ClientViewSet)
|
||||
router.register(r'locations', views.LocationViewSet)
|
||||
router.register(r'tables', views.TableViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
url(r'api/v1/', include(router.urls)),
|
||||
]
|
@@ -1,3 +1,17 @@
|
||||
from django.shortcuts import render
|
||||
from billard.models import Client, Location, Table
|
||||
from billard.serializers import ClientSerializer, LocationSerializer, TableSerializer
|
||||
from rest_framework import viewsets
|
||||
|
||||
# Create your views here.
|
||||
|
||||
class ClientViewSet(viewsets.ModelViewSet):
|
||||
queryset = Client.objects.all()
|
||||
serializer_class = ClientSerializer
|
||||
|
||||
|
||||
class LocationViewSet(viewsets.ModelViewSet):
|
||||
queryset = Location.objects.all()
|
||||
serializer_class = LocationSerializer
|
||||
|
||||
class TableViewSet(viewsets.ModelViewSet):
|
||||
queryset = Table.objects.all()
|
||||
serializer_class = TableSerializer
|
Reference in New Issue
Block a user