blob: 9e2849de0fa360e096610b2802b06e74dc9a83b6 [file] [log] [blame]
Murat Parlakisikb224cc92017-02-16 16:27:12 -08001from 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 status
7from core.models import *
8from django.forms import widgets
9from services.progran.models import *
10from xos.apibase import XOSListCreateAPIView, XOSRetrieveUpdateDestroyAPIView, XOSPermissionDenied
11from api.xosapi_helpers import PlusModelSerializer, XOSViewSet, ReadOnlyField
12import json
13
14BASE_NAME = 'progran'
15
16
17class VProgranProfileSerializer(PlusModelSerializer):
18 id = ReadOnlyField()
19 uiid = serializers.CharField(required=False)
20 profile = serializers.CharField(required=False)
21 dlrate = serializers.CharField(required=False)
22 ulrate = serializers.CharField(required=False)
23
24
25 class Meta:
26 model = VProgranProfile
27 fields = ('uiid','id', 'profile', 'dlrate' , 'ulrate')
28
29
30
31
32class VProgranImsiSerializer(PlusModelSerializer):
33 id = ReadOnlyField()
34 uiid = serializers.CharField(required=False)
35 imsi = serializers.CharField(required=False)
36 profile = serializers.CharField(required=False)
37
38
39 class Meta:
40 model = VProgranImsi
41 fields = ('uiid','id', 'imsi', "profile")
42
43
44class ProgranProfileViewSet(XOSViewSet):
45 base_name = "progran"
46 method_name = "profile"
47 method_kind = "viewset"
48 queryset = VProgranProfile.objects.all()
49 serializer_class = VProgranProfileSerializer
50
51 @classmethod
52 def get_urlpatterns(self, api_path="^"):
53 patterns = super(ProgranProfileViewSet, self).get_urlpatterns(api_path=api_path)
54
55 return patterns
56
57 def list(self, request):
58 object_list = self.filter_queryset(self.get_queryset())
59
60 serializer = self.get_serializer(object_list, many=True)
61
62 return Response(serializer.data)
63
64
65class ProgranImsiViewSet(XOSViewSet):
66 base_name = "progran"
67 method_name = "imsi"
68 method_kind = "viewset"
69 queryset = VProgranImsi.objects.all()
70 serializer_class = VProgranImsiSerializer
71
72 @classmethod
73 def get_urlpatterns(self, api_path="^"):
74 patterns = super(ProgranImsiViewSet, self).get_urlpatterns(api_path=api_path)
75
76 return patterns
77
78 def list(self, request):
79 object_list = self.filter_queryset(self.get_queryset())
80
81 serializer = self.get_serializer(object_list, many=True)
82
83 return Response(serializer.data)