Beispiel #1
0
def login_action(request):
    if request.method == 'POST':
        m_username = request.POST.get("username","")
        passwd = request.POST.get("passwd","")
        next = request.POST.get('next','')
        user = auth.authenticate(username = m_username,password = passwd)
        if not user:
            error = "用户名或密码错误"
            return render_to_response("login_required.html",locals())
        auth.login(request,user)
        request.session['user'] = m_username
        username = m_username
        msg_count = get_msg_count(username)
        if next != '':
            if next.startswith('/submitwords'):
                next = '%s%s' % ('/',next[13:])
            return HttpResponseRedirect(next)
        return render_to_response("logined.html",locals())
    
    else:
        next = request.GET.get('next','')
        return render_to_response("login_required.html",locals())
Beispiel #2
0
def home_action(request):
    sign = 'home'
    linenum = HOME_ITEM_LINES
    username = request.session.get('user','')
    msg_count = get_msg_count(username)
    new = news.objects.all()[:23]
    problems = Problem.objects.all()[:linenum]
    relaxs = Relax.objects.all()[:linenum]
    tutsaus = Tutsau.objects.all()[:linenum]
    
    home_btn = VAR_DICT['HOME_BTN_VALUE']
    home_title = VAR_DICT['HOME_TITLE_VALUE']
    home_body = VAR_DICT['HOME_BODY_VALUE']
    home_img_url = VAR_DICT['HOME_IMG_URL']
    
    ifoundyou_btn = VAR_DICT['IFOUNDYOU_BTN_VALUE']
    ifoundyou_title = VAR_DICT['IFOUNDYOU_TITLE_VALUE']
    ifoundyou_body = VAR_DICT['IFOUNDYOU_BODY_VALUE']
    ifoundyou_btn_link = VAR_DICT['IFOUNDYOU_BTN_LINK']
    ifoundyou_img_url = VAR_DICT['IFOUNDYOU_IMG_URL']
    
    problem_btn = VAR_DICT['PROBLEM_BTN_VALUE']
    problem_title = VAR_DICT['PROBLEM_TITLE_VALUE']
    problem_body = VAR_DICT['PROBLEM_BODY_VALUE']
    problem_img_url = VAR_DICT['PROBLEM_IMG_URL']
    
    relax_btn = VAR_DICT['RELAX_BTN_VALUE']
    relax_title = VAR_DICT['RELAX_TITLE_VALUE']
    relax_body = VAR_DICT['RELAX_BODY_VALUE']
    relax_img_url = VAR_DICT['RELAX_IMG_URL']
    
    tutsau_btn = VAR_DICT['TUTSAU_BTN_VALUE']
    tutsau_title = VAR_DICT['TUTSAU_TITLE_VALUE']
    tutsau_body = VAR_DICT['TUTSAU_BODY_VALUE']
    tutsau_img_url = VAR_DICT['TUTSAU_IMG_URL']
    
    return render_to_response("home.html",locals())