mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
* 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)
23 lines
612 B
Python
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
|