Beispiel #1
0
def register(request):
    	if request.method == "POST":
	    	uf = UserForm(request.POST)
	    	if uf.is_valid():
	    		userip = request.POST.get('userip')
	    		username = request.POST.get('username')
	    		password = request.POST.get('password')
	        	userauth = request.POST.get('userauth')
	        	user = User()
	        	user.userip = userip
	        	user.username = username
	        	user.password = password
	        	user.userauth = userauth
	        	user.save()

	        	return HttpResponseRedirect(reverse('login'))
    	else:
        	uf = UserForm()
    	return render_to_response('register.html',{'uf':uf})
Beispiel #2
0
def add(request):
	if request.method == "POST":
	    	uf = UserForm(request.POST)
	    	if uf.is_valid():
			userip = request.POST['userip']
			name = request.POST['username']
			pwd = request.POST['password']
			auth = request.POST['userauth']
			user = User()
			user.userip = userip
			user.username = name
			user.password = pwd
			user.userauth = auth
			user.save()
			addlog(request.session.get('userip',''),'用户添加')
			return HttpResponseRedirect(reverse('usermanage'))
	else:
        	uf = UserForm()
        	addlog(request.session.get('userip',''),'用户添加失败')
    	return render_to_response('useradd.html',{'uf':uf})