add last_seen serializer
This commit is contained in:
parent
bab9196c38
commit
ae02010203
@ -1,9 +1,15 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from billard.models import LocationData
|
||||
from billard.models import LocationData, Client
|
||||
|
||||
|
||||
class LocationDataSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = LocationData
|
||||
fields = ('client_id', 'desk_no', 'tst', 'on_off',)
|
||||
|
||||
|
||||
class ClientUpdateLastSeenSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Client
|
||||
fields = ('uuid', 'last_seen')
|
||||
|
@ -7,6 +7,7 @@ from billard import views
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register(r'locationdata', views.LocationDataViewSet)
|
||||
router.register(r'last_seen', views.ClientUpdateLastSeenViewSet)
|
||||
|
||||
app_name = 'billard'
|
||||
urlpatterns = [
|
||||
|
@ -11,7 +11,7 @@ from django.views import generic
|
||||
from rest_framework import viewsets
|
||||
|
||||
from billard.models import LocationData, Location, Client, Accounting
|
||||
from billard.serializers import LocationDataSerializer
|
||||
from billard.serializers import LocationDataSerializer, ClientUpdateLastSeenSerializer
|
||||
from billard.tasks import process_location_data
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -108,6 +108,11 @@ class LocationDataViewSet(viewsets.ModelViewSet):
|
||||
serializer_class = LocationDataSerializer
|
||||
|
||||
|
||||
class ClientUpdateLastSeenViewSet(viewsets.ModelViewSet):
|
||||
queryset = LocationData.objects.all()
|
||||
serializer_class = ClientUpdateLastSeenSerializer
|
||||
|
||||
|
||||
def process_location_data(request):
|
||||
process_location_data()
|
||||
return HttpResponse('DONE')
|
||||
|
Loading…
Reference in New Issue
Block a user