Created
July 11, 2019 12:55
-
-
Save aballah-chamakh/de769fef7330a2d2ad7958bee305b03e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.shortcuts import render | |
| from rest_framework.decorators import action | |
| from rest_framework.response import Response | |
| from rest_framework import viewsets,status,generics | |
| from .models import User,Profile | |
| from .serializers import SimpleProfileSerializer,ProfileSerializer | |
| from .UserSerializer import UserSerializer | |
| from .permissions import IsOwnerAndAuthenticated | |
| class UserViewSet(viewsets.ModelViewSet): | |
| serializer_class = UserSerializer | |
| queryset = User.objects.all() | |
| permissons_classes = (IsOwnerAndAuthenticated,) | |
| @action(methods=['GET'],detail=False) | |
| def email_exist(self,request): | |
| email = request.data.get('email') | |
| qs = User.objects.filter(email=email) | |
| if qs : | |
| return Response({'exist':True},status=status.HTTP_200_OK) | |
| else : | |
| return Response({'exist':False},status=status.HTTP_200_OK) | |
| class ProfileViewSet(viewsets.ModelViewSet): | |
| serializer_class = ProfileSerializer | |
| queryset = Profile.objects.all() | |
| permissons_classes = (IsOwnerAndAuthenticated,) | |
| lookup_field = 'slug' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment