admin(minor): remove partial API
This commit is contained in:
parent
c9714893bb
commit
3afb0d4f6d
|
@ -1,6 +0,0 @@
|
||||||
"""Versioned Admin API Urls"""
|
|
||||||
from django.conf.urls import include, url
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
url(r'^v1/', include('passbook.admin.api.v1.urls', namespace='v1')),
|
|
||||||
]
|
|
|
@ -1,22 +0,0 @@
|
||||||
"""passbook admin application API"""
|
|
||||||
from rest_framework.permissions import IsAdminUser
|
|
||||||
from rest_framework.serializers import ModelSerializer
|
|
||||||
from rest_framework.viewsets import ModelViewSet
|
|
||||||
|
|
||||||
from passbook.core.models import Application
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationSerializer(ModelSerializer):
|
|
||||||
"""Application Serializer"""
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Application
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class ApplicationViewSet(ModelViewSet):
|
|
||||||
"""Application Viewset"""
|
|
||||||
|
|
||||||
permission_classes = [IsAdminUser]
|
|
||||||
serializer_class = ApplicationSerializer
|
|
||||||
queryset = Application.objects.all()
|
|
|
@ -1,36 +0,0 @@
|
||||||
"""passbook admin gorup API"""
|
|
||||||
from rest_framework.permissions import IsAdminUser
|
|
||||||
from rest_framework.serializers import ModelSerializer, Serializer
|
|
||||||
from rest_framework.viewsets import ModelViewSet
|
|
||||||
|
|
||||||
from passbook.core.models import Group
|
|
||||||
|
|
||||||
|
|
||||||
class RecursiveField(Serializer):
|
|
||||||
"""Recursive field for manytomanyfield"""
|
|
||||||
|
|
||||||
def to_representation(self, value):
|
|
||||||
serializer = self.parent.parent.__class__(value, context=self.context)
|
|
||||||
return serializer.data
|
|
||||||
|
|
||||||
def create(self):
|
|
||||||
raise NotImplementedError()
|
|
||||||
|
|
||||||
def update(self):
|
|
||||||
raise NotImplementedError()
|
|
||||||
|
|
||||||
class GroupSerializer(ModelSerializer):
|
|
||||||
"""Group Serializer"""
|
|
||||||
|
|
||||||
children = RecursiveField(many=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Group
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
class GroupViewSet(ModelViewSet):
|
|
||||||
"""Group Viewset"""
|
|
||||||
|
|
||||||
permission_classes = [IsAdminUser]
|
|
||||||
serializer_class = GroupSerializer
|
|
||||||
queryset = Group.objects.filter(parent__isnull=True)
|
|
|
@ -1,33 +0,0 @@
|
||||||
"""passbook admin API URLs"""
|
|
||||||
from django.urls import path
|
|
||||||
from drf_yasg import openapi
|
|
||||||
from drf_yasg.views import get_schema_view
|
|
||||||
from rest_framework import permissions
|
|
||||||
from rest_framework.routers import DefaultRouter
|
|
||||||
|
|
||||||
from passbook.admin.api.v1.applications import ApplicationViewSet
|
|
||||||
from passbook.admin.api.v1.groups import GroupViewSet
|
|
||||||
from passbook.admin.api.v1.users import UserViewSet
|
|
||||||
|
|
||||||
router = DefaultRouter()
|
|
||||||
router.register('applications', ApplicationViewSet)
|
|
||||||
router.register('groups', GroupViewSet)
|
|
||||||
router.register('users', UserViewSet)
|
|
||||||
|
|
||||||
SchemaView = get_schema_view(
|
|
||||||
openapi.Info(
|
|
||||||
title="passbook Administration API",
|
|
||||||
default_version='v1',
|
|
||||||
description="Internal passbook API for Administration Interface",
|
|
||||||
contact=openapi.Contact(email="contact@snippets.local"),
|
|
||||||
license=openapi.License(name="MIT License"),
|
|
||||||
),
|
|
||||||
public=True,
|
|
||||||
permission_classes=(permissions.IsAdminUser,),
|
|
||||||
)
|
|
||||||
|
|
||||||
urlpatterns = router.urls + [
|
|
||||||
path('swagger.yml', SchemaView.without_ui(cache_timeout=0), name='schema-json'),
|
|
||||||
path('swagger/', SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
|
||||||
]
|
|
||||||
app_name = 'passbook.admin'
|
|
|
@ -1,23 +0,0 @@
|
||||||
"""passbook admin user API"""
|
|
||||||
from rest_framework.permissions import IsAdminUser
|
|
||||||
from rest_framework.serializers import ModelSerializer
|
|
||||||
from rest_framework.viewsets import ModelViewSet
|
|
||||||
|
|
||||||
from passbook.core.models import User
|
|
||||||
|
|
||||||
|
|
||||||
class UserSerializer(ModelSerializer):
|
|
||||||
"""User Serializer"""
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = User
|
|
||||||
fields = ['is_superuser', 'username', 'name', 'email', 'date_joined',
|
|
||||||
'uuid']
|
|
||||||
|
|
||||||
|
|
||||||
class UserViewSet(ModelViewSet):
|
|
||||||
"""User Viewset"""
|
|
||||||
|
|
||||||
permission_classes = [IsAdminUser]
|
|
||||||
serializer_class = UserSerializer
|
|
||||||
queryset = User.objects.all()
|
|
|
@ -77,8 +77,6 @@ urlpatterns = [
|
||||||
path('audit/', audit.AuditEntryListView.as_view(), name='audit-log'),
|
path('audit/', audit.AuditEntryListView.as_view(), name='audit-log'),
|
||||||
# Groups
|
# Groups
|
||||||
path('groups/', groups.GroupListView.as_view(), name='groups'),
|
path('groups/', groups.GroupListView.as_view(), name='groups'),
|
||||||
# API
|
|
||||||
path('api/', include('passbook.admin.api.urls')),
|
|
||||||
# Debug
|
# Debug
|
||||||
path('debug/request/', debug.DebugRequestView.as_view(), name='debug-request'),
|
path('debug/request/', debug.DebugRequestView.as_view(), name='debug-request'),
|
||||||
]
|
]
|
||||||
|
|
Reference in New Issue