From aa59b05a2dedfd65651d62bc00994d03cf34694b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 27 Feb 2020 11:40:36 +0100 Subject: [PATCH] cleanup urls --- uncloud/uncloud/urls.py | 7 +------ uncloud/uncloud_api/serializers.py | 6 ------ uncloud/uncloud_api/views.py | 7 ++----- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/uncloud/uncloud/urls.py b/uncloud/uncloud/urls.py index 23392c5..1e4c9d0 100644 --- a/uncloud/uncloud/urls.py +++ b/uncloud/uncloud/urls.py @@ -18,14 +18,12 @@ from django.urls import path, include from rest_framework import routers -from uncloud_api import views as apiviews from uncloud_vm import views as vmviews from opennebula import views as oneviews router = routers.DefaultRouter() -router.register(r'user', apiviews.UserViewSet, basename='user') - +# user / regular urls router.register(r'vm/snapshot', apiviews.VMSnapshotView, basename='VMSnapshot') router.register(r'vm/vm', vmviews.VMProductViewSet, basename='vmproduct') @@ -35,10 +33,7 @@ router.register(r'admin/opennebula', oneviews.VMViewSet, basename='opennebula') router.register(r'admin/opennebula_raw', oneviews.RawVMViewSet) -# Wire up our API using automatic URL routing. -# Additionally, we include login URLs for the browsable API. urlpatterns = [ path('', include(router.urls)), - path('admin/', admin.site.urls), # login to django itself path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) # for login to REST API ] diff --git a/uncloud/uncloud_api/serializers.py b/uncloud/uncloud_api/serializers.py index cd7fd14..89f4e83 100644 --- a/uncloud/uncloud_api/serializers.py +++ b/uncloud/uncloud_api/serializers.py @@ -1,4 +1,3 @@ -from django.contrib.auth.models import Group from django.contrib.auth import get_user_model from rest_framework import serializers @@ -7,8 +6,3 @@ class UserSerializer(serializers.ModelSerializer): class Meta: model = get_user_model() fields = ['url', 'username', 'email'] - -class GroupSerializer(serializers.HyperlinkedModelSerializer): - class Meta: - model = Group - fields = ['url', 'name'] diff --git a/uncloud/uncloud_api/views.py b/uncloud/uncloud_api/views.py index 7e5c6f9..c90b963 100644 --- a/uncloud/uncloud_api/views.py +++ b/uncloud/uncloud_api/views.py @@ -7,10 +7,7 @@ from rest_framework import viewsets, permissions, generics from rest_framework.views import APIView from rest_framework.response import Response -from uncloud_vm.models import VMProduct -from .models import VMSnapshotProduct -from .serializers import UserSerializer, GroupSerializer, VMSnapshotSerializer, VMSnapshotCreateSerializer - +from .serializers import UserSerializer import inspect import sys @@ -51,4 +48,4 @@ class UserViewSet(viewsets.ModelViewSet): permission_classes = [permissions.IsAuthenticated] def get_queryset(self): - return self.request.user \ No newline at end of file + return self.request.user