Exemplo n.º 1
0
def login(request):
    print "xxxxx"
    if request.method == 'POST':
        username = request.REQUEST.get('log_un', None)
        pwd = request.REQUEST.get('log_pwd', None)
        if username is None:
            form = LoginForm(request.POST)
            print(form)
            if form.is_valid():
                cd = form.clean()
                print(cd)
                username = cd['username']
                pwd = cd['password']
                user = auth.authenticate(username=username, password=pwd)
                if user is None:
                    message = u"login fail!"
                    print message
                    return render_to_response('success_login.html', {'message': message, },
                                          context_instance=RequestContext(request))
                else:
                    auth.login(request, user)
                    return HttpResponseRedirect(reverse('searchindex'))

            else:
                message = u"login fail!"
                print message
                return render_to_response('success_login.html', {'message': message, },
                                          context_instance=RequestContext(request))
    else:
        form = LoginForm()
        print LoginForm

        return render_to_response('login.html', {'form': form},
                                  context_instance=RequestContext(request))
Exemplo n.º 2
0
def login(request):
    print "this is test"
    if request.method == 'POST':
        username = request.REQUEST.get('log_un', None)
        pwd = request.REQUEST.get('log_pwd', None)
        code = request.REQUEST.get('log_code', None)
        if username is None:
            form = LoginForm(request.POST)
            if form.is_valid():
                cd = form.clean()
                username = cd['username']
                pwd = cd['password']
                code = cd['vcode']
                i = user_auth(request, username, pwd, code)
                if i == 1:
                    a = request.REQUEST.get('next', None)
                    if a:
                        return HttpResponseRedirect(a)
                    else:
                        return HttpResponseRedirect(reverse('search_result_m'))
                else:
                    form.valiatetype(i)
                    return render_to_response('login_m.html', {'form': form, },
                                              context_instance=RequestContext(request))
            else:
                return render_to_response('login_m.html', {'form': form, },
                                          context_instance=RequestContext(request))

        return refresh_header(request, user_auth(request, username, pwd, code))
    else:
        form = LoginForm()
        next = request.GET.get('next', None)
        return render_to_response('login_m.html', {'form': form, 'next': next},
                                  context_instance=RequestContext(request))
Exemplo n.º 3
0
def login(request):
    if request.method == 'POST':
        username = request.REQUEST.get('log_un', None)
        pwd = request.REQUEST.get('log_pwd', None)
        code = request.REQUEST.get('log_code', None)
        if username is None:
            form = LoginForm(request.POST)
            print(form)
            if form.is_valid():
                cd = form.clean()
                print(cd)
                username = cd['username']
                pwd = cd['password']
                code = cd['vcode']
                i = user_auth(request, username, pwd, code)
                if i == 1:
                    a = request.REQUEST.get('next', None)
                    if a:
                        return HttpResponseRedirect(a)
                    else:
                        return HttpResponseRedirect(reverse('searchindex'))
                else:
                    form.valiatetype(i)
                    return render_to_response('login.html', {'form': form, },
                                              context_instance=RequestContext(request))
            else:
                return render_to_response('login.html', {'form': form, },
                                          context_instance=RequestContext(request))

        return refresh_header(request, user_auth(request, username, pwd, code))
    else:
        form = LoginForm()
        next = request.GET.get('next', None)
        return render_to_response('login.html', {'form': form, 'next': next},
                                  context_instance=RequestContext(request))
Exemplo n.º 4
0
def login(request):
    if request.method == 'POST':
        username = request.REQUEST.get('log_un', None)
        pwd = request.REQUEST.get('log_pwd', None)
        code = request.REQUEST.get('log_code', None)
        if username is None:
            form = LoginForm(request.POST)
            if form.is_valid():
                cd = form.clean()
                username = cd['username']
                pwd = cd['password']
                code = cd['vcode']
                i = user_auth(request, username, pwd, code)
                if i == 1:
                    a = request.REQUEST.get('next', None)
                    if a:
                        return HttpResponseRedirect(a)
                    else:
                        user = User.objects.get(username=username)
                        login_times = user.userinformation.login_times
                        if login_times:
                            user.userinformation.login_times = int(
                                login_times) + 1
                        else:
                            user.userinformation.login_times = 1
                        user.userinformation.save()
                        return HttpResponseRedirect(reverse('searchindex'))
                else:
                    form.valiatetype(i)
                    return render_to_response(
                        'login.html', {
                            'form': form,
                        },
                        context_instance=RequestContext(request))
            else:
                return render_to_response(
                    'login.html', {
                        'form': form,
                    },
                    context_instance=RequestContext(request))

        return refresh_header(request, user_auth(request, username, pwd, code))
    else:
        form = LoginForm()
        next = request.GET.get('next', None)
        return render_to_response('login.html', {
            'form': form,
            'next': next
        },
                                  context_instance=RequestContext(request))
Exemplo n.º 5
0
def login(request):
    print "xxxxx"
    if request.method == 'POST':
        username = request.REQUEST.get('log_un', None)
        pwd = request.REQUEST.get('log_pwd', None)
        if username is None:
            form = LoginForm(request.POST)
            print(form)
            if form.is_valid():
                cd = form.clean()
                print(cd)
                username = cd['username']
                pwd = cd['password']
                user = auth.authenticate(username=username, password=pwd)
                if user is None:
                    message = u"login fail!"
                    print message
                    return render_to_response(
                        'success_login.html', {
                            'message': message,
                        },
                        context_instance=RequestContext(request))
                else:
                    auth.login(request, user)
                    return HttpResponseRedirect(reverse('searchindex'))

            else:
                message = u"login fail!"
                print message
                return render_to_response(
                    'success_login.html', {
                        'message': message,
                    },
                    context_instance=RequestContext(request))
    else:
        form = LoginForm()
        print LoginForm

        return render_to_response('login.html', {'form': form},
                                  context_instance=RequestContext(request))
Exemplo n.º 6
0
def index(request):
    hotspots = WeekHotSpot.objects.filter(status=1).order_by('?')
    if hotspots.exists():
        hs = random.sample(hotspots, 5)
    else:
        hs = []
    user = auth.get_user(request)
    print "ttttttttttttttt"
    results_right = Bid.objects.filter(process__lt=100).filter(
        term__gt=0).order_by("random_rank").order_by("term")[0:4]
    results_right.query.group_by = ['platform_id']

    results_left = Bid.objects.filter(
        process__lt=100).order_by("random_rank").order_by("-income_rate")[0:4]
    results_left.query.group_by = ['platform_id']

    if request.GET.get('register_success', None) is not None:
        form = SearchForm()
        f_l = get_user_filter(user)

        p = re.compile(
            '^13[4-9][0-9]{8}|^15[0,1,2,7,8,9][0-9]{8}|^18[2,7,8][0-9]{8}|^147[0-9]{8}|^178[0-9]{8}'
        )
        p1 = re.compile(
            '^18[0,1,9][0-9]{8}|^133[0-9]{8}|^153[0-9]{8}|^177[0-9]{8}')
        phone = user.username
        if p.match(str(phone)):
            flag1 = 1
        elif p1.match(str(phone)):
            flag1 = 2
        else:
            flag1 = 3

        return render_to_response('index.html', {
            'flag1': flag1,
            'register_success': 1,
            'form': form,
            'f_ls': f_l,
            'hs': hs,
            'results_left': results_left,
            'results_right': results_right
        },
                                  context_instance=RequestContext(request))

    if user.id is not None:
        form = SearchForm()
        f_l = get_user_filter(user)
        return render_to_response('index.html', {
            'form': form,
            'f_ls': f_l,
            'hs': hs,
            'results_left': results_left,
            'results_right': results_right
        },
                                  context_instance=RequestContext(request))
    else:
        form = RegisterForm()
        form_login = LoginForm()
        return render_to_response('index.html', {
            'form': form,
            'form_login': form_login,
            'hs': hs,
            'results_left': results_left,
            'results_right': results_right
        },
                                  context_instance=RequestContext(request))