Ejemplo n.º 1
0
from functools import partial

import commonware.log
from piston.authentication.oauth import OAuthAuthentication, views

from django.contrib.auth.models import AnonymousUser
from django.shortcuts import render

from access.middleware import ACLMiddleware
from users.models import UserProfile
from zadmin import jinja_for_django

# This allows the views in piston.authentication.oauth to cope with
# Jinja2 templates as opposed to Django templates.
# Piston view passes: template, context, request_context
jfd = lambda a, b, c: jinja_for_django(a, b, context_instance=c)
views.render_to_response = jfd

log = commonware.log.getLogger('z.api')


class AMOOAuthAuthentication(OAuthAuthentication):
    """^^^MOO!!!  Adds amo_user to the request object."""
    def is_authenticated(self, request):
        if request.user and request.user.is_authenticated():
            return True

        # To avoid patching django-piston, use a partial to cope with
        # piston not sending in request when called later.
        self.challenge = partial(self._challenge, request=request)
Ejemplo n.º 2
0
def jfd(a, b, c):
    return jinja_for_django(a, b, context_instance=c)
Ejemplo n.º 3
0
def jfd(a, b, c):
    return jinja_for_django(a, b, context_instance=c)
Ejemplo n.º 4
0
from functools import partial

import commonware.log
import jingo
from piston.authentication.oauth import OAuthAuthentication, views

from django.contrib.auth.models import AnonymousUser

from access.middleware import ACLMiddleware
from users.models import UserProfile
from zadmin import jinja_for_django

# This allows the views in piston.authentication.oauth to cope with
# Jinja2 templates as opposed to Django templates.
# Piston view passes: template, context, request_context
jfd = lambda a, b, c: jinja_for_django(a, b, context_instance=c)
views.render_to_response = jfd


log = commonware.log.getLogger('z.api')


class AMOOAuthAuthentication(OAuthAuthentication):
    """^^^MOO!!!  Adds amo_user to the request object."""

    def is_authenticated(self, request):
        if request.user and request.user.is_authenticated():
            return True

        # To avoid patching django-piston, use a partial to cope with
        # piston not sending in request when called later.