Beispiel #1
0
class MediaForm(form.Form):
    name = fields.TextField('Name')
    url = fields.TextField('Url')
    woeid = fields.TextField('woeid',description='http://woe.spum.org/ or http://developer.yahoo.com/geo/geoplanet')

    # Form list
    keywords = InlineFieldList(InlineFormField(KeywordForm))
    hosts = InlineFieldList(InlineFormField(HostsForm))
Beispiel #2
0
    def conv_List(self, model, field, kwargs):
        if field.field is None:
            raise ValueError(
                'ListField "%s" must have field specified for model %s' %
                (field.name, model))

        if isinstance(field.field, ReferenceField):
            loader = getattr(self.view, '_form_ajax_refs', {}).get(field.name)
            if loader:
                return AjaxSelectMultipleField(loader, **kwargs)

            kwargs['widget'] = form.Select2Widget(multiple=True)

            # TODO: Support AJAX multi-select
            doc_type = field.field.document_type
            return mongo_fields.ModelSelectMultipleField(model=doc_type,
                                                         **kwargs)

        # Create converter
        view = self._get_subdocument_config(field.name)
        converter = self.clone_converter(view)

        if field.field.choices:
            kwargs['multiple'] = True
            return converter.convert(model, field.field, kwargs)

        unbound_field = converter.convert(model, field.field, {})
        return InlineFieldList(unbound_field, min_entries=0, **kwargs)
Beispiel #3
0
    def conv_List(self, model, field, kwargs):
        if field.field is None:
            raise ValueError(
                'ListField "%s" must have field specified for model %s' %
                (field.name, model))

        if isinstance(field.field, ReferenceField):
            kwargs['widget'] = form.Select2Widget(multiple=True)

            doc_type = field.field.document_type
            return mongo_fields.ModelSelectMultipleField(model=doc_type,
                                                         **kwargs)

        # Create converter
        view = self._get_subdocument_config(field.name)
        converter = self.clone_converter(view)

        if field.field.choices:
            kwargs['multiple'] = True
            return converter.convert(model, field.field, kwargs)

        unbound_field = converter.convert(model, field.field, {})
        kwargs = {
            'validators': [],
            'filters': [],
        }
        return InlineFieldList(unbound_field, min_entries=0, **kwargs)
Beispiel #4
0
class UserForm(form.Form):
    name = fields.TextField('Name')
    email = fields.TextField('Email')
    password = fields.TextField('Password')

    # Inner form
    inner = InlineFormField(InnerForm)

    # Form list
    form_list = InlineFieldList(InlineFormField(InnerForm))
Beispiel #5
0
    def conv_List(self, model, field, kwargs):
        if isinstance(field.field, ReferenceField):
            kwargs['widget'] = form.Select2Widget(multiple=True)

            doc_type = field.field.document_type
            return fields.ModelSelectMultipleField(model=doc_type, **kwargs)
        if field.field.choices:
            kwargs['multiple'] = True
            return self.convert(model, field.field, kwargs)

        unbound_field = self.convert(model, field.field, {})
        kwargs = {
            'validators': [],
            'filters': [],
        }
        return InlineFieldList(unbound_field, min_entries=0, **kwargs)
Beispiel #6
0
class CitiesForm(form.Form):
    city = fields.TextField('city')
    woeid = fields.TextField('woeid',description='http://woe.spum.org/ or http://developer.yahoo.com/geo/geoplanet')
    neighborhoods = InlineFieldList(InlineFormField(NeighborhoodsForm))