Example #1
0
def login(request):
    next_url = request.GET.get('next', '') or get_referer_view(request)

    if request.method == 'GET':
        form = LoginUserInfoModelForm()
    else:
        form = LoginUserInfoModelForm(request.POST)
        if form.is_valid():
            response = HttpResponseRedirect(next_url)
            response.set_cookie('usr', smart_str(form.cleaned_data['username']))
            return response

    return render(
        request,
        'accounts/login.html',
        dict(backlinks=BACKLINKS, form=form, next=next_url)
    )
Example #2
0
def login(request):
    next_url = request.GET.get('next', '') or get_referer_view(request)
    form = LoginUserInfoModelForm()

    if request.method == 'POST':
        form = LoginUserInfoModelForm(request.POST)
        if form.is_valid():
            response = redirect(next_url)
            response.set_cookie('usr', smart_str(form.cleaned_data['username']), MAX_AGE)
            return response

    usr, ui = getUsrUI(request)
    display_bg, slide_image_classify = (ui.display_bg, ui.classify) if ui else (True, '')

    return render(
        request,
        'accounts/login.html',
        dict(backlinks=BACKLINKS, form=form, next=next_url, display_bg=display_bg, slide_image_classify=slide_image_classify)
    )
Example #3
0
def login(request):
    next_url = request.GET.get('next', '') or get_referer_view(request)
    form = LoginUserInfoModelForm()

    if request.method == 'POST':
        form = LoginUserInfoModelForm(request.POST)
        if form.is_valid():
            response = redirect(next_url)
            response.set_cookie('usr',
                                smart_str(form.cleaned_data['username']),
                                MAX_AGE)
            return response

    usr, ui = getUsrUI(request)
    display_bg, slide_image_classify = (ui.display_bg,
                                        ui.classify) if ui else (True, '')

    return render(
        request, 'accounts/login.html',
        dict(backlinks=BACKLINKS,
             form=form,
             next=next_url,
             display_bg=display_bg,
             slide_image_classify=slide_image_classify))