Added settings to serializer.

This commit is contained in:
Antoine Nguyen
2018-10-05 14:06:59 +02:00
parent 19f2af429a
commit 865c9226c1
4 changed files with 49 additions and 4 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ PLUGIN_BASE_DIR = os.path.dirname(__file__)
ADMIN_STATS_FILES = {
"dev": os.path.join(
PLUGIN_BASE_DIR, "../frontend/webpack-stats.json"),
PLUGIN_BASE_DIR, "../../frontend/webpack-stats.json"),
"prod": os.path.join(
PLUGIN_BASE_DIR, "static/admin/webpack-stats.json")
}
+20 -1
View File
@@ -575,5 +575,24 @@ GLOBAL_PARAMETERS_STRUCT = collections.OrderedDict([
)
})
])
})
}),
("dashboard", {
"label": ugettext_lazy("Dashboard"),
"params": collections.OrderedDict([
("rss_feed_url", {
"label": ugettext_lazy("Custom RSS feed"),
"help_text": ugettext_lazy(
"Display custom RSS feed to resellers and domain "
"administrators"
)
}),
("hide_features_widget", {
"label": ugettext_lazy("Hide features widget"),
"help_text": ugettext_lazy(
"Hide features widget for resellers and domain "
"administrators"
)
}),
])
}),
])
+23
View File
@@ -6,6 +6,8 @@ from django.contrib.auth import password_validation
from rest_framework import serializers
from modoboa.lib import fields as lib_fields
from . import constants
@@ -66,6 +68,27 @@ class CoreGlobalParametersSerializer(serializers.Serializer):
ldap_groups_search_base = serializers.CharField(
default="", required=False, allow_blank=True)
# Dashboard settings
rss_feed_url = serializers.URLField(allow_blank=True)
hide_features_widget = serializers.BooleanField(default=False)
# Notification settings
sender_address = lib_fields.DRFEmailFieldUTF8(
default="noreply@yourdomain.test")
# API settings
enable_api_communication = serializers.BooleanField(default=True)
check_new_versions = serializers.BooleanField(default=True)
send_statistics = serializers.BooleanField(default=True)
# Misc settings
inactive_account_threshold = serializers.IntegerField(default=30)
top_notifications_check_interval = serializers.IntegerField(default=30)
log_maximum_age = serializers.IntegerField(default=365)
items_per_page = serializers.IntegerField(default=30)
default_top_redirection = serializers.ChoiceField(
default="user", choices=[])
def validate_ldap_user_dn_template(self, value):
try:
value % {"user": "toto"}
+5 -2
View File
@@ -40,8 +40,11 @@ class ModoAPIClient(object):
def local_core_version(self):
"""Return the version installed locally."""
if self._local_core_version is None:
self._local_core_version = pkg_resources.get_distribution(
"modoboa").version
try:
self._local_core_version = pkg_resources.get_distribution(
"modoboa").version
except pkg_resources.DistributionNotFound:
self._local_core_version = "unknown"
return self._local_core_version
def list_extensions(self):