def permission_required(perm, login_url=None):
    """Replacement for django.contrib.auth.decorators.permission_required that
    returns 403 Forbidden if the user is already logged in.
    """

    return user_passes_test(lambda u: u.has_perm(perm), login_url=login_url)
Replacement for django.contrib.auth.decorators.permission_required that
    returns 403 Forbidden if the user is already logged in.