django.contrib.admin.opts - python examples

Here are the examples of the python api django.contrib.admin.opts taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

3 View Complete Implementation : admintools.py
Copyright GNU Lesser General Public License v3.0
Author : 007gzs
def check_perms(*perms):
    """
    Returns True if the given request has permissions to manage an object.
    """

    def inner(func):
        @wraps(func)
        def wrapper(admin, request, *args, **kwargs):
            opts = admin.opts
            for perm in perms:
                codename = get_permission_codename(perm, opts)
                if not request.user.has_perm(
                                "%s.%s" % (opts.app_label, codename)):
                    raise PermissionDenied
            return func(admin, request, *args, **kwargs)

        return wrapper

    return inner