# Path: folivora/utils/jabber.py
# def is_valid_jid(jabber):
#     return _jabber_re.match(jabber) is not None


from django.db import models
from django.utils.translation import ugettext as _
from django.forms import ValidationError, fields
from django.forms.models import ModelFormMetaclass, ModelForm as BaseModelForm
from floppyforms import widgets, forms
from .jabber import is_valid_jid
    """
    def __new__(cls, name, bases, attrs):
        if BaseModelForm not in bases and 'Meta' in attrs:
            meta = attrs['Meta']
            model = meta.model
            widgets = getattr(meta, 'widgets', None)
            if not widgets:
                widgets = meta.widgets = {}
            for field in model._meta.fields:
                if isinstance(field, models.AutoField):
                    continue
                if field.choices:
                    widgets[field.name] = widget_map[models.ForeignKey]
                elif type(field) in widget_map and field.name not in widgets:
                    widgets[field.name] = widget_map[type(field)]

        return super(FloppyFormsModelMetaclass, cls).__new__(cls, name,
            bases, attrs)


class ModelForm(forms.LayoutRenderer, BaseModelForm):
    """Model form which does incorporate floppyforms layout renderer"""
    __metaclass__ = FloppyFormsModelMetaclass


class JabberField(fields.CharField):
    def clean(self, value):
        value = value.strip()
        if not value and not self.required:
            return value

# Path: folivora/utils/jabber.py
# def is_valid_jid(jabber):
#     return _jabber_re.match(jabber) is not None


# Path: folivora/utils/forms.py
from django.db import models
from django.utils.translation import ugettext as _
from django.forms import ValidationError, fields
from django.forms.models import ModelFormMetaclass, ModelForm as BaseModelForm
from floppyforms import widgets, forms
from .jabber import is_valid_jid

    """
    def __new__(cls, name, bases, attrs):
        if BaseModelForm not in bases and 'Meta' in attrs:
            meta = attrs['Meta']
            model = meta.model
            widgets = getattr(meta, 'widgets', None)
            if not widgets:
                widgets = meta.widgets = {}
            for field in model._meta.fields:
                if isinstance(field, models.AutoField):
                    continue
                if field.choices:
                    widgets[field.name] = widget_map[models.ForeignKey]
                elif type(field) in widget_map and field.name not in widgets:
                    widgets[field.name] = widget_map[type(field)]

        return super(FloppyFormsModelMetaclass, cls).__new__(cls, name,
            bases, attrs)


class ModelForm(forms.LayoutRenderer, BaseModelForm):
    """Model form which does incorporate floppyforms layout renderer"""
    __metaclass__ = FloppyFormsModelMetaclass


class JabberField(fields.CharField):
    def clean(self, value):
        value = value.strip()
        if not value and not self.required:
            return value

        if not is_valid_jid(value):