コード例 #1
0
def url_with_auth(regex, view, kwargs=None, name=None, prefix=''):
    """
    if view is string based, must be a full path
    """
    from djapiauth.auth import api_auth
    if isinstance(view, six.string_types):  # view is a string, must be full path
        return url(regex, api_auth(import_string(prefix + "." + view if prefix else view)))
    elif isinstance(view, (list, tuple)):  # include
        return url(regex, view, name, prefix, **kwargs)
    else:  # view is an object
        return url(regex, api_auth(view))
コード例 #2
0
ファイル: utility.py プロジェクト: chenty/dj-api-auth
def url_with_auth(regex, view, kwargs=None, name=None, prefix=''):
    """
    if view is string based, must be a full path
    """
    from djapiauth.auth import api_auth
    if isinstance(view, six.string_types):  # view is a string, must be full path
        return url(regex, api_auth(import_by_path(prefix + "." + view if prefix else view)))
    elif isinstance(view, (list, tuple)):  # include
        return url(regex, view, name, prefix, **kwargs)
    else:  # view is an object
        return url(regex, api_auth(view))
コード例 #3
0
ファイル: utility.py プロジェクト: nixphix/dj-api-auth
 def as_view(cls, **initkwargs):
     from djapiauth.auth import api_auth
     view = super(AuthMixin, cls).as_view(**initkwargs)
     view = api_auth(view) if cls.api_auth else view
     return csrf_exempt(view) if "post" in cls.http_method_names else view
コード例 #4
0
ファイル: utility.py プロジェクト: chenty/dj-api-auth
 def as_view(cls, **initkwargs):
     from djapiauth.auth import api_auth
     view = super(AuthMixin, cls).as_view(**initkwargs)
     view = api_auth(view) if cls.api_auth else view
     return csrf_exempt(view) if "post" in cls.http_method_names else view
コード例 #5
0
ファイル: utility.py プロジェクト: neilchencn/dj-api-auth
 def as_view(cls, **initkwargs):
     from djapiauth.auth import api_auth
     view = super(AuthMixin, cls).as_view(**initkwargs)
     return api_auth(view) if cls.api_auth else view