Пример #1
0
class BlockItemForm(Form):
    item = fields.Select2TagsField(
        'Item', [
            validators.required(),
            validators.CallableValidator(validate_block_item)
        ],
        save_as_list=False,
        render_kw=get_block_item_kw,
        description=('Enter absolute URL `http://..` or `/foo/bar.html` '
                     'or select existing content.'))
    name = fields.StringField('Name', description='optional')
    order = fields.IntegerField('Order', default=0)
    item_type = fields.SmartSelect2Field(
        'Type', [validators.required()],
        default='link',
        choices=lambda: [
            item
            for item in app.config.get('BLOCK_ITEM_TYPES', [('link', 'Link')])
        ])

    custom_vars = InlineFieldList(InlineFormField(CustomVariablesForm),
                                  label='Custom Variables')

    index_id = fields.HiddenField('index_id')
    category_id = fields.HiddenField('category_id')
    tag_id = fields.HiddenField('tag_id')
    author_id = fields.HiddenField('author_id')
    url_id = fields.HiddenField('url_id')
    content_type = fields.HiddenField('content_type', default='block_item')
Пример #2
0
class BaseForm(Form):

    title = fields.StringField(
        'Title', [validators.required()],
        description='TIP: `My Title` turns to`my-title.html` url')
    summary = fields.TextAreaField('Summary')
    category = fields.Select2TagsField(
        'Category', [validators.CallableValidator(validate_category)],
        save_as_list=False,
        render_kw=get_category_kw,
        default=get_default_category,
        description=('TIP: Leave blank and url will be `/my-title.html`<br>'
                     '`foo` url will be `/foo/my-title.html` <br>'
                     '`foo/bar` url will be `/foo/bar/my-title.html` <br>'))
    authors = fields.Select2TagsField('Authors', [validators.required()],
                                      save_as_list=True,
                                      render_kw=get_authors_kw,
                                      default=get_default_author)
Пример #3
0
class BaseForm(Form):

    title = fields.StringField(_('Title'), [validators.required()])
    # todo: validade existing category/title
    summary = fields.TextAreaField(_('Summary'))
    category = fields.Select2TagsField(
        _('Category'),
        [validators.CallableValidator(validate_category)],
        save_as_list=False,
        render_kw={'data-tags': '["hello", "world"]'},
        # todo: ^ settings.default_categories + db_query
        default='general'
        # todo: default should come from settings
    )
    authors = fields.Select2TagsField(
        _('Authors'),
        [validators.required()],
        save_as_list=True,
        render_kw={'data-tags': '["Bruno Rocha", "Karla Magueta"]'},
        # todo: settings.default_authors + current + db_query
        default=['Bruno Rocha']
        # todo: default should be current user if auth else O.S user else ?
    )