def setUp(self): user = User(username="******", email="*****@*****.**") user.set_password("password") user.save() p=player(name="username", user=user) p.save() user = User(username="******", email="*****@*****.**") user.set_password("password") user.save() p=player(name="username1", user=user) p.save() class request(): user=User.objects.get(username="******") body="""{"x":1,"y":1}""" class request1(): user=User.objects.get(username="******") body="""{"x":1,"y":1}""" r=request() add_unit(r) r.body="""{"x":3,"y":4}""" add_unit(r) r=request1() add_unit(r)
def sign_up_in(request): c = {} c.update(csrf(request)) if request.method=='POST': c["form"]=sigh_up_form(request.POST) #c["error_message"]="vvedena forma" if c['form'].is_valid(): f=c['form'] user = User(username=f.cleaned_data["username"], email=f.cleaned_data["email"]) user.set_password(f.cleaned_data["password"]) user.save() p=player(name=f.cleaned_data["username"], user=user) p.save() u=authenticate(username=user.username, password=f.cleaned_data["password"]) print u login(request,u) return redirect('game:index') print "valid" else: c["form"]=sigh_up_form() return render_to_response('login/sign_up.html', c)