django-orchestra-test/orchestra/contrib/settings/apps.py
Santiago L 70042f3b5c Regenerate commit inicio 2023/07/09
commit 0f26b5a8e0
Author: jorgepastorr <jorge.pastor.rr@gmail.com>
Date:   Sun Jul 9 07:51:51 2023 +0000
Repo:   https://gitea.pangea.org/pangea/django-orchestra.git
2023-11-17 13:25:13 +01:00

31 lines
1 KiB
Python

from django.apps import AppConfig
from django.core.checks import register, Error
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _
from orchestra.core import administration
from . import Setting
class SettingsConfig(AppConfig):
name = 'orchestra.contrib.settings'
verbose_name = 'Settings'
def ready(self):
administration.register_view('settings_setting_change', verbose_name=_("Setting"),
verbose_name_plural=_("Settings"),
icon='Multimedia-volume-control.png')
@register()
def check_settings(app_configs, **kwargs):
""" perfroms all the validation """
messages = []
for name, setting in Setting.settings.items():
try:
setting.validate()
except ValidationError as exc:
msg = "Error validating setting with value %s: %s" % (setting.value, exc)
messages.append(Error(msg, obj=name, id='settings.E001'))
return messages