def needs_mailbox():
    def decorator(f):
        @wraps(f)
        def wrapped_f(request, *args, **kwargs):
            if hasattr(request.user, "mailbox"):
                return f(request, *args, **kwargs)
            raise PermDeniedException(_("A mailbox is required"))
        return wrapped_f
    return decorator
Check if the current user owns at least one mailbox
dataset/ETHPy150Open tonioo/modoboa/modoboa/admin/lib.py/needs_mailbox