# Path: varnish_bans_manager/core/models/setting.py
# class Setting(Model):
#     __metaclass__ = SettingMetaclass
# 
#     name = models.CharField(
#         max_length=255,
#         null=False,
#         db_index=True,
#         unique=True
#     )
#     value = JSONField(
#         max_length=1024,
#         null=False
#     )
#     created_at = models.DateTimeField(
#         auto_now_add=True,
#         null=False
#     )
#     updated_at = models.DateTimeField(
#         auto_now=True,
#         null=False
#     )


from django.conf import settings
from django import forms
from django.utils.translation import ugettext_lazy as _
from varnish_bans_manager.core.models import Setting
        max_length=1024,
        required=False)

    notify_bans = forms.BooleanField(
        help_text=_(
            'Adjust VBM settings file to use a different e-mail address.'),
        required=False)

    def __init__(self, *args, **kwargs):
        super(GeneralForm, self).__init__(*args, **kwargs)
        self.fields['host_matching_variable'].help_text = _(
            'If not specified, defaults to <code>%s</code> for lurker '
            'friendly bans.'
        ) % Setting.DEFAULT_HOST_MATCHING_VARIABLE
        self.fields['url_matching_variable'].help_text = _(
            'If not specified, defaults to <code>%s</code> for lurker '
            'friendly bans.'
        ) % Setting.DEFAULT_URL_MATCHING_VARIABLE
        self.fields['notify_bans'].label = _(
            'Deliver periodical ban submission reports to <code>%s</code>.'
        ) % settings.VBM_NOTIFICATIONS_EMAIL
        for field_name in self.fields.keys():
            self.initial[field_name] = getattr(Setting, field_name)

    def save(self):
        for field_name in self.fields.keys():
            value = self.cleaned_data.get(field_name)
            if isinstance(value, basestring):
                value = value.strip()
            if value == '':

# Path: varnish_bans_manager/core/models/setting.py
# class Setting(Model):
#     __metaclass__ = SettingMetaclass
# 
#     name = models.CharField(
#         max_length=255,
#         null=False,
#         db_index=True,
#         unique=True
#     )
#     value = JSONField(
#         max_length=1024,
#         null=False
#     )
#     created_at = models.DateTimeField(
#         auto_now_add=True,
#         null=False
#     )
#     updated_at = models.DateTimeField(
#         auto_now=True,
#         null=False
#     )


# Path: varnish_bans_manager/core/forms/settings.py
from django.conf import settings
from django import forms
from django.utils.translation import ugettext_lazy as _
from varnish_bans_manager.core.models import Setting

        max_length=1024,
        required=False)

    notify_bans = forms.BooleanField(
        help_text=_(
            'Adjust VBM settings file to use a different e-mail address.'),
        required=False)

    def __init__(self, *args, **kwargs):
        super(GeneralForm, self).__init__(*args, **kwargs)
        self.fields['host_matching_variable'].help_text = _(
            'If not specified, defaults to <code>%s</code> for lurker '
            'friendly bans.'
        ) % Setting.DEFAULT_HOST_MATCHING_VARIABLE
        self.fields['url_matching_variable'].help_text = _(
            'If not specified, defaults to <code>%s</code> for lurker '
            'friendly bans.'
        ) % Setting.DEFAULT_URL_MATCHING_VARIABLE
        self.fields['notify_bans'].label = _(
            'Deliver periodical ban submission reports to <code>%s</code>.'
        ) % settings.VBM_NOTIFICATIONS_EMAIL
        for field_name in self.fields.keys():
            self.initial[field_name] = getattr(Setting, field_name)

    def save(self):
        for field_name in self.fields.keys():
            value = self.cleaned_data.get(field_name)
            if isinstance(value, basestring):
                value = value.strip()
            if value == '':

                delattr(Setting, field_name)