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))
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))
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
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