From 1d5d3a5ed3852ff801967ca0b8cb5a41d092c4ba Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 2 Apr 2020 08:15:36 +0200 Subject: [PATCH] Provide default value to ALLOWED_RESOURCES. --- musician/settings.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/musician/settings.py b/musician/settings.py index 1fafdd2..6ef7f86 100644 --- a/musician/settings.py +++ b/musician/settings.py @@ -1,3 +1,4 @@ +from collections import defaultdict from django.conf import settings @@ -5,22 +6,28 @@ def getsetting(name): value = getattr(settings, name, None) return value or DEFAULTS.get(name) +# provide a default value allowing to overwrite it for each type of account +def allowed_resources_default_factory(): + return {'mailbox': 2} DEFAULTS = { # allowed resources limit hardcoded because cannot be retrieved from the API. - "ALLOWED_RESOURCES": { - 'INDIVIDUAL': + "ALLOWED_RESOURCES": defaultdict( + allowed_resources_default_factory, { - # 'disk': 1024, - # 'traffic': 2048, - 'mailbox': 2, - }, - 'ASSOCIATION': { - # 'disk': 5 * 1024, - # 'traffic': 20 * 1024, - 'mailbox': 10, + 'INDIVIDUAL': + { + # 'disk': 1024, + # 'traffic': 2048, + 'mailbox': 2, + }, + 'ASSOCIATION': { + # 'disk': 5 * 1024, + # 'traffic': 20 * 1024, + 'mailbox': 10, + } } - }, + ), "URL_DB_PHPMYADMIN": "https://phpmyadmin.pangea.org/", "URL_MAILTRAIN": "https://mailtrain.org/", "URL_SAAS_GITLAB": "https://gitlab.pangea.org/",