uncloud-mravi/uncloud/uncloud_api/views.py
Nico Schottelius aa59b05a2d cleanup urls
2020-02-27 11:40:36 +01:00

51 lines
1.5 KiB
Python

from django.shortcuts import render
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from rest_framework import viewsets, permissions, generics
from rest_framework.views import APIView
from rest_framework.response import Response
from .serializers import UserSerializer
import inspect
import sys
import re
# maybe drop or not --- we need something to guide the user!
# class ProductsViewSet(viewsets.ViewSet):
# permission_classes = [permissions.IsAuthenticated]
# def list(self, request):
# clsmembers = []
# for modules in [ 'uncloud_api.models', 'uncloud_vm.models' ]:
# clsmembers.extend(inspect.getmembers(sys.modules[modules], inspect.isclass))
# products = []
# for name, c in clsmembers:
# # Include everything that ends in Product, but not Product itself
# m = re.match(r'(?P<pname>.+)Product$', name)
# if m:
# products.append({
# 'name': m.group('pname'),
# 'description': c.description,
# 'recurring_period': c.recurring_period,
# 'pricing_model': c.pricing_model()
# }
# )
# return Response(products)
class UserViewSet(viewsets.ModelViewSet):
serializer_class = UserSerializer
permission_classes = [permissions.IsAuthenticated]
def get_queryset(self):
return self.request.user