Files
modoboa/lib/decorators.py
T
Antoine Nguyen b7d77254ce wip: Resellers and limits (see #105)
* Added support for migrations
* Big refactoring of the admin code

done: Support for SHA256 algorithm to store passwords (fix #195)
done: admin models refactoring (fix #196)
2012-01-27 13:51:29 +01:00

23 lines
612 B
Python

# coding: utf-8
"""
:mod:`decorators` --- common decorators
---------------------------------------
"""
from functools import wraps
from exceptions import NeedsMailboxException
def needs_mailbox():
"""Check if the current user owns at least one mailbox
Some applications (the webmail for example) need a mailbox to
work.
"""
def decorator(f):
@wraps(f)
def wrapped_f(request, *args, **kwargs):
if request.user.has_mailbox:
return f(request, *args, **kwargs)
raise NeedsMailboxException()
return wrapped_f
return decorator