Esempio n. 1
0
def login_form(request):
    """
    When a user registers through a social network we need some
    additional information.
    """
    error = None
    if request.method == "POST":
        profile_form = ProfileSocialRegistrationForm(request.POST)
        user_form = UserSocialRegistrationForm(request.POST)
        if user_form.is_valid() and profile_form.is_valid():
            session_variable = setting("SOCIAL_AUTH_PARTIAL_PIPELINE_KEY", "partial_pipeline")
            request.session["saved_username"] = user_form.cleaned_data["username"]
            # LF: request.session['saved_privacy_level'] = profile_form.cleaned_data['privacy_level']
            request.session["saved_wants_newsletter"] = profile_form.cleaned_data["wants_newsletter"]
            request.session["saved_city"] = profile_form.cleaned_data["city"]
            request.session["saved_uses_nickname"] = profile_form.cleaned_data["uses_nickname"]
            request.session["saved_says_is_politician"] = profile_form.cleaned_data["says_is_politician"]
            backend = request.session[session_variable]["backend"]
            return redirect("socialauth_complete", backend=backend)
        else:
            error = _("Form is invalid")

    else:
        user_form = UserSocialRegistrationForm()
        profile_form = ProfileSocialRegistrationForm()

    return render_to_response(
        "login_form.html",
        {"error": error, "user_form": user_form, "profile_form": profile_form},
        RequestContext(request),
    )
Esempio n. 2
0
def login_form(request):
    """
    When a user registers through a social network we need some
    additional information.
    """
    error = None
    if request.method == 'POST':
        profile_form = ProfileSocialRegistrationForm(request.POST)
        user_form = UserSocialRegistrationForm(request.POST)
        if user_form.is_valid() and profile_form.is_valid():
            session_variable = setting('SOCIAL_AUTH_PARTIAL_PIPELINE_KEY',
                                       'partial_pipeline')
            request.session['saved_username'] = user_form.cleaned_data[
                'username']
            #LF: request.session['saved_privacy_level'] = profile_form.cleaned_data['privacy_level']
            request.session[
                'saved_wants_newsletter'] = profile_form.cleaned_data[
                    'wants_newsletter']
            request.session['saved_city'] = profile_form.cleaned_data['city']
            request.session['saved_uses_nickname'] = profile_form.cleaned_data[
                'uses_nickname']
            request.session[
                'saved_says_is_politician'] = profile_form.cleaned_data[
                    'says_is_politician']
            backend = request.session[session_variable]['backend']
            return redirect('socialauth_complete', backend=backend)
        else:
            error = _('Form is invalid')

    else:
        user_form = UserSocialRegistrationForm()
        profile_form = ProfileSocialRegistrationForm()

    return render_to_response('login_form.html', {
        'error': error,
        'user_form': user_form,
        'profile_form': profile_form,
    }, RequestContext(request))
Esempio n. 3
0
def form(request):
    error = None
    if request.method == 'POST':
        profile_form = ProfileSocialRegistrationForm(request.POST)
        user_form = UserSocialRegistrationForm(request.POST)
        if user_form.is_valid() and profile_form.is_valid():
            session_variable = setting('SOCIAL_AUTH_PARTIAL_PIPELINE_KEY', 'partial_pipeline')
            request.session['saved_username'] = user_form.cleaned_data['username']
            request.session['saved_privacy_level'] = profile_form.cleaned_data['privacy_level']
            request.session['saved_wants_newsletter'] = profile_form.cleaned_data['wants_newsletter']
            request.session['saved_city'] = profile_form.cleaned_data['city']
            backend = request.session[session_variable]['backend']
            return redirect('socialauth_complete', backend=backend)
        else:
            error = _('Form is invalid')

    user_form = UserSocialRegistrationForm()
    profile_form = ProfileSocialRegistrationForm()
    return render_to_response('form.html', {
            'error': error,
            'user_form': user_form,
            'profile_form': profile_form,
            }, RequestContext(request))