def permission_required(perm, login_url=None, raise_exception=False):
def check_perms(user):<EOL><INDENT>if not getattr(settings, '<STR_LIT>',<EOL>app_settings.REQUIRE_LOGIN):<EOL><INDENT>return True<EOL><DEDENT>if user.has_perm(perm):<EOL><INDENT>return True<EOL><DEDENT>if raise_exception:  <EOL><INDENT>raise PermissionDenied<EOL><DEDENT>return False<EOL><DEDENT>return user_passes_test(check_perms, login_url=login_url)<EOL>
Re-implementation of the permission_required decorator, honors settings.

If ``DASHBOARD_REQUIRE_LOGIN`` is False, this decorator will always return
``True``, otherwise it will check for the permission as usual.