mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
29 lines
776 B
Python
29 lines
776 B
Python
"""Modoboa limits utilities."""
|
|
|
|
from . import constants
|
|
|
|
|
|
def get_user_limit_templates():
|
|
"""Return defined templates."""
|
|
return list(constants.DEFAULT_USER_LIMITS.items())
|
|
|
|
|
|
def get_domain_limit_templates():
|
|
"""Return defined templates."""
|
|
return list(constants.DEFAULT_DOMAIN_LIMITS.items())
|
|
|
|
|
|
def move_pool_resource(owner, user):
|
|
"""Move resource from one pool to another.
|
|
|
|
When an account doesn't need a pool anymore, we move the
|
|
associated resource to the pool of its owner.
|
|
"""
|
|
for name, ltpl in get_user_limit_templates():
|
|
l = user.userobjectlimit_set.get(name=name)
|
|
if l.max_value < 0:
|
|
continue
|
|
ol = owner.userobjectlimit_set.get(name=name)
|
|
ol.max_value += l.max_value
|
|
ol.save()
|