Exemple #1
0
class ConfigFormField(JSONFormField):

    def __init__(self, *args, **kwargs):
        super(ConfigFormField, self).__init__(*args, **kwargs)
        self.label = kwargs.get('label', _('Configuration'))
        self.widget = ConfigWidget()

    def set_config(self, config):
        self.config = config
        self.widget.add_config_widgets(config)

    def clean(self, value):
        value = super(ConfigFormField, self).clean(value)
        for name, param in self.config.items():
            if not param.is_valid(value.get(name, None)):
                raise ValidationError(_('Error in "%(name)s" field') % {'name': param.label})
        return value
Exemple #2
0
class ConfigFormField(JSONFormField):
    def __init__(self, *args, **kwargs):
        super(ConfigFormField, self).__init__(*args, **kwargs)
        self.label = kwargs.get('label', _('Configuration'))
        self.widget = ConfigWidget()

    def set_config(self, config):
        self.config = config
        self.widget.add_config_widgets(config)

    def clean(self, value):
        value = super(ConfigFormField, self).clean(value)
        for name, param in self.config.items():
            if not param.is_valid(value.get(name, None)):
                raise ValidationError(
                    _('Error in "%(name)s" field') % {'name': param.label})
        return value
Exemple #3
0
 def __init__(self, *args, **kwargs):
     super(ConfigFormField, self).__init__(*args, **kwargs)
     self.label = kwargs.get('label', _('Configuration'))
     self.widget = ConfigWidget()
Exemple #4
0
 def __init__(self, *args, **kwargs):
     super(ConfigFormField, self).__init__(*args, **kwargs)
     self.label = kwargs.get('label', _('Configuration'))
     self.widget = ConfigWidget()