Default mailbox quota should not be greater than quota.

see #1035
This commit is contained in:
Antoine Nguyen
2017-02-20 16:57:38 +01:00
parent c677de4e17
commit 6ecb50deab
3 changed files with 23 additions and 0 deletions
+11
View File
@@ -27,6 +27,17 @@ class DomainSerializer(serializers.ModelSerializer):
"pk", "name", "quota", "default_mailbox_quota", "enabled", "type",
)
def validate(self, data):
"""Check quota values."""
quota = data["quota"]
default_mailbox_quota = data["default_mailbox_quota"]
if quota != 0 and default_mailbox_quota > quota:
raise serializers.ValidationError({
"default_mailbox_quota":
_("Cannot be greater than domain quota")
})
return data
def create(self, validated_data):
"""Set permissions."""
domain = models.Domain(**validated_data)