示例#1
0
文件: views.py 项目: reclusegit/blog
def regist(req):
    if req.method == 'POST':
        uf = UserForm(req.POST)
        if uf.is_valid():
            username = uf.cleaned_data['username']
            password = uf.cleaned_data['password']
            User.objects.create(username=username, password=password)
            return HttpResponseRedirect('/login/')
    else:
        uf = UserForm()
    return render_to_response('regist.html', {'uf': uf})
示例#2
0
文件: views.py 项目: reclusegit/blog
def regist(req):
	if req.method == 'POST':
		uf = UserForm(req.POST)
		if uf.is_valid():
			username = uf.cleaned_data['username']
			password = uf.cleaned_data['password']
			User.objects.create(username = username, password = password)
			return HttpResponseRedirect('/login/')
	else:
		uf = UserForm()
	return render_to_response('regist.html', {'uf':uf})
示例#3
0
文件: views.py 项目: reclusegit/blog
def login(req):
	if req.method == 'POST':
		uf = UserForm(req.POST)
		if uf.is_valid():
			username = uf.cleaned_data['username']
			password = uf.cleaned_data['password']
			user = User.objects.filter(username__exact = username, password__exact = password)
			if user:
				req.session['username'] = username
				# read issue type from db
				issue = IssueType.objects.all()
				#return HttpResponseRedirect('/index/', {'issue':issue})
				return render_to_response('index.html', {'issue':issue})
			else:
				return HttpResponseRedirect('/login/')
	else:
		uf = UserForm()
	return render_to_response('login.html', {'uf':uf})
示例#4
0
文件: views.py 项目: reclusegit/blog
def login(req):
    if req.method == 'POST':
        uf = UserForm(req.POST)
        if uf.is_valid():
            username = uf.cleaned_data['username']
            password = uf.cleaned_data['password']
            user = User.objects.filter(username__exact=username,
                                       password__exact=password)
            if user:
                req.session['username'] = username
                # read issue type from db
                issue = IssueType.objects.all()
                #return HttpResponseRedirect('/index/', {'issue':issue})
                return render_to_response('index.html', {'issue': issue})
            else:
                return HttpResponseRedirect('/login/')
    else:
        uf = UserForm()
    return render_to_response('login.html', {'uf': uf})