summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-03-07 15:16:09 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-03-07 15:16:09 +0000
commitf39d78d9993d62e8967d093ceeb52c5fc4054120 (patch)
tree4222eca0dd0c5490961a7dde72aceacb731ef3aa
parent7227b5d35ccb95582dc879adddb5a93e93bb9647 (diff)
downloadpykolab-f39d78d9993d62e8967d093ceeb52c5fc4054120.tar.gz
Update dynamicquota plugin to also take the domain default quota, if any, as a parameter.
-rw-r--r--pykolab/plugin/dynamicquota/__init__.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/pykolab/plugin/dynamicquota/__init__.py b/pykolab/plugin/dynamicquota/__init__.py
index ac2fd6e..00c9799 100644
--- a/pykolab/plugin/dynamicquota/__init__.py
+++ b/pykolab/plugin/dynamicquota/__init__.py
@@ -23,9 +23,7 @@ class KolabDynamicquota(object):
"""
def __init__(self, conf=None):
- if not conf == None:
- self.conf = conf
- pass
+ self.conf = conf
def set_user_folder_quota(self, kw={}, args=()):
"""
@@ -36,10 +34,18 @@ class KolabDynamicquota(object):
- quota (integer, in KB)
"""
- (used, current_quota, new_quota) = args
+ #print args
+
+ (used, current_quota, new_quota, default_quota) = args
# Escape the user without quota
if new_quota == 0:
+ # Unless default quota is set
+ if default_quota > 0:
+ #print "new quota is 0, but default quota > 0, returning default quota"
+ return default_quota
+
+ #print "new quota is 0, and default quota is no larger then 0, returning 0"
return 0
# Make your adjustments here, for example:
@@ -48,8 +54,16 @@ class KolabDynamicquota(object):
# is over 90%
if new_quota < int(float(used) * 1.1):
+ #print "new quota is smaller then 110%% of what is currently used, returning 110%% of used"
new_quota = int(float(used) * 1.1)
elif new_quota > int(float(used) * 1.1):
+ # TODO: If the current quota in IMAP had been set to 0, but we want to apply quota, and
+ # 0 is current_quota, 90% of that is still 0...
+ #print "new quota is larger then 110%% of what is currently used, returning 90%% of current quota"
new_quota = int(float(current_quota) * 0.9)
+ if default_quota > new_quota:
+ #print "default quota is more then the calculated new quota"
+ return default_quota
+
return new_quota