Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 4
0
def other_services(request, template_name="account/other_services.html"):
    from zwitschern.utils import twitter_verify_credentials
    from zwitschern.pownce_utils import pownce_verify_credentials
    twitter_form = TwitterForm(request.user)
    pownce_form = PownceForm(request.user)
    twitter_authorized = False
    pownce_authorized = False
    if request.method == "POST":
        twitter_form = TwitterForm(request.user, request.POST)

        if request.POST['actionType'] == 'saveTwitter':
            if twitter_form.is_valid():
                from zwitschern.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()
                
        if request.POST['actionType'] == 'savePownce':
            pownce_form = PownceForm(request.user, request.POST)     
            if pownce_form.is_valid():
                from zwitschern.pownce_utils import pownce_account_raw
                pownce_account = pownce_account_raw(request.POST['usernamep'], request.POST['passwordp'])
                pownce_authorized = pownce_verify_credentials(pownce_account)
                if not pownce_authorized:
                    request.user.message_set.create(message="Pownce authentication failed")
                else:
                    pownce_form.save()
    else:
        from zwitschern.utils import twitter_account_for_user
        from zwitschern.pownce_utils import pownce_account_for_user
        twitter_account = twitter_account_for_user(request.user)
        pownce_account  = pownce_account_for_user(request.user)
        twitter_authorized = twitter_verify_credentials(twitter_account)
        pownce_authorized = pownce_verify_credentials(pownce_account)
        twitter_form = TwitterForm(request.user)
        pownce_form = PownceForm(request.user)
    return render_to_response(template_name, {
        "twitter_form": twitter_form,
        "twitter_authorized": twitter_authorized,
        "pownce_form": pownce_form,
        "pownce_authorized":pownce_authorized,
    }, context_instance=RequestContext(request))
Ejemplo n.º 5
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))