Esempio n. 1
0
def register (request):
    if request.method != 'POST':
        return HttpResponse ("There is POST method only.")

    keys = request.POST.keys()
    response = {}
    if "API" not in keys:
        response["Error"] = {"ErrorCode": "666", "ErrorDescription": "There is no API parameter."}
        return HttpResponse (json.dumps(response))
    else:
        api_ver = request.POST.get("API")
    if api_ver != "1":
        response["Error"] = {"ErrorCode": "777", "ErrorDescription": "Wrong API version."}
        return HttpResponse (json.dumps(response))
    else:
        response["Error"] = {"ErrorCode": "", "ErrorDescription": ""}
    
    from restserver.pipture.models import PipUsers

    user = PipUsers()
    user.save()
        
    response["SessionKey"] = "%s" % (user.Token)
    response["UUID"] = "%s" % (user.UserUID)
    return HttpResponse (json.dumps(response))
Esempio n. 2
0
def register_pip_user (email, password, first_name,last_name):
    from restserver.pipture.models import PipUsers
    from django.core.exceptions import ValidationError, NON_FIELD_ERRORS

    token = str(uuid.uuid1())
    p = PipUsers(Email=email, Password=password, FirstName=first_name, LastName=last_name, Token=token)
    try:
        p.save()
    except ValidationError:
        return None
    else:
        return token
Esempio n. 3
0
 def get_pip_user(self):
     new_purchaser = Purchasers()
     new_purchaser.save()
     pip_user = PipUsers(Purchaser=new_purchaser)
     pip_user.save()
     return pip_user
Esempio n. 4
0
 def get_pip_user(self):
     new_purchaser = Purchasers()
     new_purchaser.save()
     pip_user = PipUsers(Purchaser=new_purchaser)
     pip_user.save()
     return pip_user