| Server IP : 85.214.239.14 / Your IP : 216.73.216.122 Web Server : Apache/2.4.65 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/3/cwd/srv/modoboa/env/lib/python3.5/site-packages/modoboa/limits/ |
Upload File : |
"""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, _definition in get_user_limit_templates():
user_limit = user.userobjectlimit_set.get(name=name)
if user_limit.max_value < 0:
continue
owner_limit = owner.userobjectlimit_set.get(name=name)
owner_limit.max_value += user_limit.max_value
owner_limit.save()