blob: 8492d933d140dbad98456c3fa08c5563a8517b4e [file] [log] [blame]
Gabe Black4c040b72016-11-17 22:35:04 +00001from rest_framework.decorators import api_view
2from rest_framework.response import Response
3from rest_framework.reverse import reverse
4from rest_framework import serializers
5from rest_framework import generics
6from rest_framework import viewsets
7from rest_framework import status
8from rest_framework.decorators import detail_route, list_route
9from rest_framework.views import APIView
10from core.models import *
11from django.forms import widgets
12from django.conf.urls import patterns, url
13from api.xosapi_helpers import PlusModelSerializer, XOSViewSet, ReadOnlyField
14from django.shortcuts import get_object_or_404
15from xos.apibase import XOSListCreateAPIView, XOSRetrieveUpdateDestroyAPIView, XOSPermissionDenied
16from xos.exceptions import *
17import json
18import subprocess
19from services.activetest.models import ActiveTestService, VpmaService, Qt600Service
20
21class ActiveTestSerializer(PlusModelSerializer):
22 id = ReadOnlyField()
23 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
24
25 class Meta:
26 model = ActiveTestService
27 fields = ('humanReadableName',
28 'id')
29
30 def getHumanReadableName(self, obj):
31 return obj.__unicode__()
32
33class ActiveTestViewSet(XOSViewSet):
34 base_name = "activetest"
35 method_name = "activetest"
36 method_kind = "viewset"
37 queryset = ActiveTestService.get_service_objects().all()
38 serializer_class = ActiveTestSerializer
39
40 @classmethod
41 def get_urlpatterns(self, api_path="^"):
42 patterns = super(ActiveTestViewSet, self).get_urlpatterns(api_path=api_path)
43 return patterns
44
45 def list(self, request):
46 object_list = self.filter_queryset(self.get_queryset())
47 serializer = self.get_serializer(object_list, many=True)
48 return Response(serializer.data)
49
50############################################################################################
51
52class VpmaSerializer(PlusModelSerializer):
53 id = ReadOnlyField()
54 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
55
56 class Meta:
57 model = VpmaService
58 fields = ('humanReadableName',
59 'id')
60
61 def getHumanReadableName(self, obj):
62 return obj.__unicode__()
63
64class VpmaViewSet(XOSViewSet):
65 base_name = "vpma"
66 method_name = "vpma"
67 method_kind = "viewset"
68 queryset = VpmaService.get_service_objects().all()
69 serializer_class = VpmaSerializer
70
71 @classmethod
72 def get_urlpatterns(self, api_path="^"):
73 patterns = super(VpmaViewSet, self).get_urlpatterns(api_path=api_path)
74 return patterns
75
76 def list(self, request):
77 object_list = self.filter_queryset(self.get_queryset())
78 serializer = self.get_serializer(object_list, many=True)
79 return Response(serializer.data)
80
81class Qt600Serializer(PlusModelSerializer):
82 id = ReadOnlyField()
83 humanReadableName = serializers.SerializerMethodField("getHumanReadableName")
84
85 class Meta:
86 model = Qt600Service
87 fields = ('humanReadableName',
88 'id')
89
90 def getHumanReadableName(self, obj):
91 return obj.__unicode__()
92
93class Qt600ViewSet(XOSViewSet):
94 base_name = "qt600"
95 method_name = "qt600"
96 method_kind = "viewset"
97 queryset = Qt600Service.get_service_objects().all()
98 serializer_class = Qt600Serializer
99
100 @classmethod
101 def get_urlpatterns(self, api_path="^"):
102 patterns = super(Qt600ViewSet, self).get_urlpatterns(api_path=api_path)
103 return patterns
104
105 def list(self, request):
106 object_list = self.filter_queryset(self.get_queryset())
107 serializer = self.get_serializer(object_list, many=True)
108 return Response(serializer.data)