Browse Source

add api views

Saypina Valentina 1 year ago
parent
commit
3bb9e0e0b4

+ 10 - 1
apiviews/__init__.py

@@ -1 +1,10 @@
-from .documents import DocumentsMVS
+from .client import ClientMVS
+from .company import CompanyMVS
+from .documents import DocumentsMVS
+from .orders import OrdersMVS
+from .permissions import PermissionsMVS
+from .provider import ProviderMVS
+from .relationship import RelationshipMVS
+from .resource import ResourceMVS
+from .service import ServiceMVS
+from .servicetype import ServiceTypeMVS

+ 10 - 0
apiviews/client.py

@@ -0,0 +1,10 @@
+from metaservicesynced.serializer import ClientSerializer
+from rest_framework import viewsets, permissions
+from metaservicesynced.models import Client
+
+class ClientMVS(viewsets.ModelViewSet):
+
+    queryset = Client.objects.all()
+    serializer_class = ClientSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    permission_classes = [permissions.IsAuthenticated]

+ 10 - 0
apiviews/company.py

@@ -0,0 +1,10 @@
+from metaservicesynced.serializer import CompanySerializer
+from rest_framework import viewsets, permissions
+from metaservicesynced.models import Company
+
+class CompanyMVS(viewsets.ModelViewSet):
+
+    queryset = Company.objects.all()
+    serializer_class = CompanySerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    permission_classes = [permissions.IsAuthenticated]

+ 2 - 8
apiviews/documents.py

@@ -1,15 +1,9 @@
+from django.http import HttpResponse
 from metaservicesynced.serializer import DocumentsSerializer
-from rest_framework import viewsets, permissions, exceptions
-from rest_framework.authentication import TokenAuthentication
-from rest_framework.decorators import action
+from rest_framework import viewsets, permissions
 from metaservicesynced.models import Documents
-from rest_framework.views import APIView
-from rest_framework.response import Response
 
 class DocumentsMVS(viewsets.ModelViewSet):
-    """
-    
-    """
 
     queryset = Documents.objects.all()
     serializer_class = DocumentsSerializer

+ 10 - 0
apiviews/orders.py

@@ -0,0 +1,10 @@
+from metaservicesynced.serializer import OrdersSerializer
+from rest_framework import viewsets, permissions
+from metaservicesynced.models import Orders
+
+class OrdersMVS(viewsets.ModelViewSet):
+
+    queryset = Orders.objects.all()
+    serializer_class = OrdersSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    permission_classes = [permissions.IsAuthenticated]

+ 10 - 0
apiviews/permissions.py

@@ -0,0 +1,10 @@
+from metaservicesynced.serializer import PermissionsSerializer
+from rest_framework import viewsets, permissions
+from metaservicesynced.models import Permissions
+
+class PermissionsMVS(viewsets.ModelViewSet):
+
+    queryset = Permissions.objects.all()
+    serializer_class = PermissionsSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    permission_classes = [permissions.IsAuthenticated]

+ 10 - 0
apiviews/provider.py

@@ -0,0 +1,10 @@
+from metaservicesynced.serializer import ProviderSerializer
+from rest_framework import viewsets, permissions
+from metaservicesynced.models import Provider
+
+class ProviderMVS(viewsets.ModelViewSet):
+
+    queryset = Provider.objects.all()
+    serializer_class = ProviderSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    permission_classes = [permissions.IsAuthenticated]

+ 10 - 0
apiviews/relationship.py

@@ -0,0 +1,10 @@
+from metaservicesynced.serializer import RelationshipSerializer
+from rest_framework import viewsets, permissions
+from metaservicesynced.models import Relationship
+
+class RelationshipMVS(viewsets.ModelViewSet):
+
+    queryset = Relationship.objects.all()
+    serializer_class = RelationshipSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    permission_classes = [permissions.IsAuthenticated]

+ 10 - 0
apiviews/resource.py

@@ -0,0 +1,10 @@
+from metaservicesynced.serializer import ResourceSerializer
+from rest_framework import viewsets, permissions
+from metaservicesynced.models import Resource
+
+class ResourceMVS(viewsets.ModelViewSet):
+
+    queryset = Resource.objects.all()
+    serializer_class = ResourceSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    permission_classes = [permissions.IsAuthenticated]

+ 10 - 0
apiviews/service.py

@@ -0,0 +1,10 @@
+from metaservicesynced.serializer import ServiceSerializer
+from rest_framework import viewsets, permissions
+from metaservicesynced.models import Service
+
+class ServiceMVS(viewsets.ModelViewSet):
+
+    queryset = Service.objects.all()
+    serializer_class = ServiceSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    permission_classes = [permissions.IsAuthenticated]

+ 10 - 0
apiviews/servicetype.py

@@ -0,0 +1,10 @@
+from metaservicesynced.serializer import ServiceTypeSerializer
+from rest_framework import viewsets, permissions
+from metaservicesynced.models import ServiceType
+
+class ServiceTypeMVS(viewsets.ModelViewSet):
+
+    queryset = ServiceType.objects.all()
+    serializer_class = ServiceTypeSerializer
+    #permission_classes = [IsOwnerOrReadOnly]
+    permission_classes = [permissions.IsAuthenticated]

+ 10 - 1
serializer/__init__.py

@@ -1 +1,10 @@
-from .documents import DocumentsSerializer
+from .client import ClientSerializer
+from .company import CompanySerializer
+from .documents import DocumentsSerializer
+from .orders import OrdersSerializer
+from .permissions import PermissionsSerializer
+from .provider import ProviderSerializer
+from .relationship import RelationshipSerializer
+from .resource import ResourceSerializer
+from .service import ServiceSerializer
+from .servicetype import ServiceTypeSerializer

+ 7 - 0
serializer/client.py

@@ -0,0 +1,7 @@
+from rest_framework import serializers
+from metaservicesynced.models import Client
+
+class ClientSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Client
+        exclude = ["id"]

+ 7 - 0
serializer/company.py

@@ -0,0 +1,7 @@
+from rest_framework import serializers
+from metaservicesynced.models import Company
+
+class CompanySerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Company
+        exclude = ["id"]

+ 7 - 0
serializer/orders.py

@@ -0,0 +1,7 @@
+from rest_framework import serializers
+from metaservicesynced.models import Orders
+
+class OrdersSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Orders
+        exclude = ["id"]

+ 7 - 0
serializer/permissions.py

@@ -0,0 +1,7 @@
+from rest_framework import serializers
+from metaservicesynced.models import Permissions
+
+class PermissionsSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Permissions
+        exclude = ["id"]

+ 7 - 0
serializer/provider.py

@@ -0,0 +1,7 @@
+from rest_framework import serializers
+from metaservicesynced.models import Provider
+
+class ProviderSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Provider
+        exclude = ["id"]

+ 7 - 0
serializer/relationship.py

@@ -0,0 +1,7 @@
+from rest_framework import serializers
+from metaservicesynced.models import Relationship
+
+class RelationshipSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Relationship
+        exclude = ["id"]

+ 7 - 0
serializer/resource.py

@@ -0,0 +1,7 @@
+from rest_framework import serializers
+from metaservicesynced.models import Resource
+
+class ResourceSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Resource
+        exclude = ["id"]

+ 7 - 0
serializer/service.py

@@ -0,0 +1,7 @@
+from rest_framework import serializers
+from metaservicesynced.models import Service
+
+class ServiceSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Service
+        exclude = ["id"]

+ 7 - 0
serializer/servicetype.py

@@ -0,0 +1,7 @@
+from rest_framework import serializers
+from metaservicesynced.models import ServiceType
+
+class ServiceTypeSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = ServiceType
+        exclude = ["id"]

+ 0 - 1
tests.py

@@ -1,3 +1,2 @@
 from django.test import TestCase
-
 # Create your tests here.

+ 12 - 3
urls.py

@@ -1,10 +1,19 @@
-from metaservicesynced.apiviews import DocumentsMVS
+from metaservicesynced.apiviews import *
 from rest_framework import routers
 from django.urls import path, include
 
-router = routers.SimpleRouter()
+router = routers.DefaultRouter()
+router.register(r'client', ClientMVS)
+router.register(r'company', CompanyMVS)
 router.register(r'documents', DocumentsMVS)
+router.register(r'orders', OrdersMVS)
+router.register(r'permissions', PermissionsMVS)
+router.register(r'provider', ProviderMVS)
+router.register(r'relationship', RelationshipMVS)
+router.register(r'resource', ResourceMVS)
+router.register(r'service', ServiceMVS)
+router.register(r'servicetype', ServiceTypeMVS)
 
 urlpatterns = [  
-    path('api/', include(router.urls), name="documents"),
+    path('api/', include(router.urls), name="metasynced"),
 ]