示例#1
0
def register(req):
    context = {}
    if req.method == "POST":
        username = req.POST.get('username')
        password = req.POST.get('password')
        password_two = req.POST.get('password_two')
        print username, password, password_two
        user = User.objects.filter(username=username)
        if user:
            req.session['username'] = username
            return HttpResponse('用户名已经被占用')
        elif password == password_two:
            print "----"
            user = User()
            user.username = username
            user.password = password
            print "--------"
            user.save()
            print username, password, password_two
            #return HttpResponse(u'恭喜你!注册成功,您的用户名为'+username)
            return HttpResponseRedirect('/login/',
                                        context_instance=RequestContext(req))
        else:
            return HttpResponse(u'您两次输入的密码不匹配,请重新输入')
    else:
        uf = UserForm()
    return render_to_response('register.html',
                              context_instance=RequestContext(req))
示例#2
0
def register(req):
    context={}
    if req.method == "POST":
        username=req.POST.get('username')
        password=req.POST.get('password')
        password_two=req.POST.get('password_two')
        print username,password,password_two
        user=User.objects.filter(username=username)
        if user:
            req.session['username']=username
            return HttpResponse('用户名已经被占用')
        elif password == password_two:
            print "----"
            user = User()
            user.username=username
            user.password=password
            print "--------"
            user.save()
            print username,password,password_two
            #return HttpResponse(u'恭喜你!注册成功,您的用户名为'+username)
            return HttpResponseRedirect('/login/',context_instance=RequestContext(req))
        else:
            return HttpResponse(u'您两次输入的密码不匹配,请重新输入') 
    else:
         uf=UserForm()
    return render_to_response('register.html',context_instance=RequestContext(req))
示例#3
0
def __create_brother_if_possible(semester, brother_status, first_name,
                                 last_name, caseid):
    if User.objects.filter(username=caseid).exists():
        user = User.objects.get(username=caseid)
    elif caseid != "":
        user = User()
        user.username = caseid
        user.save()
    else:
        pass  # nothing to do here since the if below will return false
        # ie `user` is never accessed

    # if able to add, create the brother with the given data
    if __can_brother_be_added(first_name, last_name, caseid):
        new_brother = Brother()
        new_brother.user = user
        new_brother.first_name = first_name
        new_brother.last_name = last_name
        new_brother.case_ID = user.username
        new_brother.birthday = datetime.date.today()
        new_brother.semester = semester
        new_brother.brother_status = brother_status
        new_brother.save()