Exemple #1
0
def other_services(request, template_name="account/other_services.html"):
    from microblogging.utils import twitter_verify_credentials
    twitter_form = TwitterForm(request.user)
    twitter_authorized = False
    if request.method == "POST":
        twitter_form = TwitterForm(request.user, request.POST)

        if request.POST['actionType'] == 'saveTwitter':
            if twitter_form.is_valid():
                from microblogging.utils import twitter_account_raw
                twitter_account = twitter_account_raw(request.POST['username'],
                                                      request.POST['password'])
                twitter_authorized = twitter_verify_credentials(
                    twitter_account)
                if not twitter_authorized:
                    request.user.message_set.create(
                        message="Twitter authentication failed")
                else:
                    twitter_form.save()
    else:
        from microblogging.utils import twitter_account_for_user
        twitter_account = twitter_account_for_user(request.user)
        twitter_authorized = twitter_verify_credentials(twitter_account)
        twitter_form = TwitterForm(request.user)
    return render_to_response(template_name, {
        "twitter_form": twitter_form,
        "twitter_authorized": twitter_authorized,
    },
                              context_instance=RequestContext(request))
Exemple #2
0
def other_services(request, template_name="account/other_services.html"):
    from microblogging.utils import twitter_verify_credentials
    twitter_form = TwitterForm(request.user)
    twitter_authorized = False
    if request.method == "POST":
        twitter_form = TwitterForm(request.user, request.POST)

        if request.POST['actionType'] == 'saveTwitter':
            if twitter_form.is_valid():
                from microblogging.utils import twitter_account_raw
                twitter_account = twitter_account_raw(
                    request.POST['username'], request.POST['password'])
                twitter_authorized = twitter_verify_credentials(
                    twitter_account)
                if not twitter_authorized:
                    request.user.message_set.create(
                        message=ugettext("Twitter authentication failed"))
                else:
                    twitter_form.save()
    else:
        from microblogging.utils import twitter_account_for_user
        twitter_account = twitter_account_for_user(request.user)
        twitter_authorized = twitter_verify_credentials(twitter_account)
        twitter_form = TwitterForm(request.user)
    return render_to_response(template_name, {
        "twitter_form": twitter_form,
        "twitter_authorized": twitter_authorized,
    }, context_instance=RequestContext(request))
Exemple #3
0
def other_services(request, **kwargs):

    from microblogging.utils import twitter_verify_credentials

    template_name = kwargs.pop("template_name", "account/other_services.html")

    group, bridge = group_and_bridge(kwargs)

    twitter_form = TwitterForm(request.user)
    twitter_authorized = False
    if request.method == "POST":
        twitter_form = TwitterForm(request.user, request.POST)

        if request.POST["actionType"] == "saveTwitter":
            if twitter_form.is_valid():
                from microblogging.utils import twitter_account_raw

                twitter_account = twitter_account_raw(request.POST["username"], request.POST["password"])
                twitter_authorized = twitter_verify_credentials(twitter_account)
                if not twitter_authorized:
                    messages.add_message(request, messages.ERROR, ugettext("Twitter authentication failed"))
                else:
                    twitter_form.save()
                    messages.add_message(request, messages.SUCCESS, ugettext(u"Successfully authenticated."))
    else:
        from microblogging.utils import twitter_account_for_user

        twitter_account = twitter_account_for_user(request.user)
        twitter_authorized = twitter_verify_credentials(twitter_account)
        twitter_form = TwitterForm(request.user)

    ctx = group_context(group, bridge)
    ctx.update({"twitter_form": twitter_form, "twitter_authorized": twitter_authorized})

    return render_to_response(template_name, RequestContext(request, ctx))
Exemple #4
0
def other_services(request, **kwargs):
    
    from microblogging.utils import twitter_verify_credentials
    
    template_name = kwargs.pop("template_name", "account/other_services.html")
    
    group, bridge = group_and_bridge(kwargs)
    
    twitter_form = TwitterForm(request.user)
    twitter_authorized = False
    if request.method == "POST":
        twitter_form = TwitterForm(request.user, request.POST)
        
        if request.POST["actionType"] == "saveTwitter":
            if twitter_form.is_valid():
                from microblogging.utils import twitter_account_raw
                twitter_account = twitter_account_raw(
                    request.POST["username"], request.POST["password"])
                twitter_authorized = twitter_verify_credentials(
                    twitter_account)
                if not twitter_authorized:
                    messages.add_message(request, messages.ERROR,
                        ugettext("Twitter authentication failed")
                    )
                else:
                    twitter_form.save()
                    messages.add_message(request, messages.SUCCESS,
                        ugettext(u"Successfully authenticated.")
                    )
    else:
        from microblogging.utils import twitter_account_for_user
        twitter_account = twitter_account_for_user(request.user)
        twitter_authorized = twitter_verify_credentials(twitter_account)
        twitter_form = TwitterForm(request.user)
    
    ctx = group_context(group, bridge)
    ctx.update({
        "twitter_form": twitter_form,
        "twitter_authorized": twitter_authorized,
    })
    
    return render_to_response(template_name, RequestContext(request, ctx))