Esempio n. 1
0
def signUp(request):
    serializer_context = {
            'request': request,
        }
    #print request.body
    if request.method == 'POST':
        req = json.loads((request.body).decode())
        username = req['username']
        password = req['password']
        email = req['email']
        firstname = req['firstname']
        lastname = req['lastname']
        
        #print("a")
        #username = request.GET.get('username','')
        #firstname = request.GET.get('firstname', '')
        #lastname = request.GET.get('lastname', '')
        #email = request.GET.get('email', '')
        #password = request.GET.get('password', '')
        if username is not '' and password is not '':
            newUser = User.objects.create_user(username, email, password)
            if firstname is not '' and lastname is not '':
                newUser.first_name = firstname
                newUser.last_name = lastname
            newUser.save()
            if newUser is not None:
                queryset = project_api.get_current_user_by_username(newUser.username)
                serializer = userSerializer(queryset,context=serializer_context, many=True)
                return JSONResponse(serializer.data,status=200)
Esempio n. 2
0
    def userInfo(self, request, userName=None):
        serializer_context = {
            'request': request,
        }

        if userName is None:
            queryset = User.objects.all()
        else:
            queryset = project_api.get_current_user_by_username(userName)
            
        serializer = userSerializer(queryset,context=serializer_context, many=True)
        return Response(serializer.data)