ungleich-otp/ungleichotp/otpauth/views.py
Nico Schottelius cd75870e42 Addd more todos
2018-11-17 19:00:48 +01:00

31 lines
867 B
Python

from django.shortcuts import render
from rest_framework import viewsets
from rest_framework.parsers import JSONParser
from otpauth.serializer import VerifySerializer
from django.http import HttpResponse, JsonResponse
import json
class ModelVerifyViewSet(viewsets.ModelViewSet):
serializer_class = VerifySerializer
def get_queryset(self):
return None
class VerifyViewSet(viewsets.ViewSet):
serializer_class = VerifySerializer
def create(self, request):
data = JSONParser().parse(request)
serializer = VerifySerializer(data=data)
if serializer.is_valid():
print("is valid")
print(serializer)
#serializer.save()
return JsonResponse(serializer.data, status=201)
return JsonResponse(serializer.errors, status=400)
def get_queryset(self):
return []