Пример #1
0
def test_create_game(request):
    response = '<html><h3>Creating Sample Data:</h3><p>Player</p><p>Sport</><p>Field</p><p>Game</p>'
    p = Player(name='Sean', password='******')
    p.save()
    s = Sport(name='BasketBall')
    s.save()
    f = Field(name = 'wilson')
    f.save()
    g = Games(creator=p, location=f, when_created = datetime.now(), start_time = datetime.now(), end_time=datetime.now(), private=True, visible=False, sport_type=s)
    g.save()
    response = response + '<p><b>Successful</b></p><h3>Created</h3>'
    response = response + '<p>'+str(p)+'</p>'+'<p>'+str(s)+'</p>'    
    response = response + '<p>'+str(f)+'</p><p>'+str(g)+'</p>'
    return HttpResponse(response, content_type="text/html")
Пример #2
0
def create_user(request):
    body = json.loads(request.body)
    username = body['Username']
    password = body['Password']
    h = hashlib.md5()
    h.update(password)
    password = h.hexdigest()
    email = body['Email']
    phone = body['Phone']
    
    overlap = Player.objects.filter(name=username).count()
    new_player = True
    if overlap:
      new_player = False
    else:
      p = Player(name=username, password=password, email=email, phone=phone)
      p.save()
    return HttpResponse(new_player, content_type="text/plain")