コード例 #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
ファイル: formats.py プロジェクト: gmsjy/quokka_ng
class BaseEditForm(BaseForm):
    """Edit form with all missing fields except `content`"""

    # content_type = fields.PassiveStringField(
    #     'Type',
    #     render_kw=READ_ONLY
    # )
    # content_format = fields.PassiveStringField(
    #     'Format',
    #     render_kw=READ_ONLY
    # )

    tags = fields.Select2TagsField('Tags',
                                   save_as_list=True,
                                   render_kw=get_tags_kw)
    date = fields.DateTimeField('Date', [validators.required()],
                                default=dt.datetime.now)
    modified = fields.HiddenField('Modified')
    slug = fields.StringField('Slug')
    # TODO: validate slug collision
    language = fields.SmartSelect2Field(
        'Language',
        choices=lambda: [(lng, lng) for lng in current_app.config.get(
            'BABEL_LANGUAGES', ['en'])],
        default=get_default_language)
    # translations = fields.HiddenField('Translations')
    # todo: ^ create action 'add translation'
    published = fields.BooleanField('Status',
                                    render_kw={
                                        'data-toggle': "toggle",
                                        'data-on': "Published",
                                        'data-off': "Draft",
                                        "data-onstyle": 'success'
                                    })
コード例 #3
0
class BaseEditForm(BaseForm):
    """Edit form with all missing fields except `content`"""

    content_type = fields.PassiveStringField(_('Type'), render_kw=READ_ONLY)
    content_format = fields.PassiveStringField(_('Format'),
                                               render_kw=READ_ONLY)

    tags = fields.Select2TagsField(_('Tags'), save_as_list=True)
    # todo: ^ provide settings.default_tags + db_query
    date = fields.DateTimeField(_('Date'), [validators.required()],
                                default=dt.datetime.now)
    # todo: ^default should be now
    modified = fields.HiddenField(_('Modified'))
    # todo: ^populate on save
    slug = fields.StringField(_('Slug'))
    # todo: create based on category / title
    language = fields.SmartSelect2Field(
        _('Language'),
        choices=lambda: [(lng, lng) for lng in current_app.config.get(
            'BABEL_LANGUAGES', ['en'])])
    translations = fields.HiddenField(_('Translations'))
    # todo: ^ create action 'add translation'
    published = fields.BooleanField(_('Status'),
                                    render_kw={
                                        'data-toggle': "toggle",
                                        'data-on': _("Published"),
                                        'data-off': _("Draft"),
                                        "data-onstyle": 'success'
                                    })
コード例 #4
0
class CreateForm(BaseForm):
    """Default create form where content format is chosen"""
    content_type = fields.SelectField(_('Type'), [validators.required()],
                                      choices=[('article', _('Article')),
                                               ('page', _('Page'))])
    content_format = fields.SmartSelect2Field(
        _('Format'), [validators.required()],
        choices=get_content_format_choices)
コード例 #5
0
class EditContentForm(BaseContentForm):
    slug = fields.StringField('Slug')
    lang = fields.SmartSelect2Field(
        'Language',
        choices=lambda: [(lng, lng) for lng in current_app.config.get(
            'BABEL_LANGUAGES', ['en'])])
    translations = fields.HiddenField('Translations')
    status = fields.HiddenField('status')
    content = fields.TextAreaField('Content')
コード例 #6
0
ファイル: formats.py プロジェクト: gmsjy/quokka_ng
class CreateForm(BaseForm):
    """Default create form where content format is chosen"""
    content_type = fields.SelectField('Type', [validators.required()],
                                      choices=[('article', 'Article'),
                                               ('page', 'Page')])
    content_format = fields.SmartSelect2Field(
        'Format',
        [validators.required()],
        choices=get_content_format_choices,
        # TODO: remove thsi `allow_blank` once select3 submit on enter is fix
        allow_blank=True)
コード例 #7
0
class CreateForm(BaseForm):
    """Default create form where content format is chosen"""
    # TODO: Make content_type an optional field by ASK_CONTENT_TYPE config
    # content_type = fields.SelectField(
    #     'Type',
    #     [validators.required()],
    #     choices=[('article', 'Article'), ('page', 'Page')]
    # )
    content_format = fields.SmartSelect2Field(
        'Format',
        [validators.required()],
        choices=get_content_format_choices,
        # TODO: remove this `allow_blank` once select2 submit on enter is fix
        allow_blank=True)
コード例 #8
0
class BaseEditForm(BaseForm):
    """Edit form with all missing fields except `content`"""

    # content_type = fields.PassiveStringField(
    #     'Type',
    #     render_kw=READ_ONLY
    # )
    # content_format = fields.PassiveStringField(
    #     'Format',
    #     render_kw=READ_ONLY
    # )

    tags = fields.Select2TagsField('Tags',
                                   save_as_list=True,
                                   render_kw=get_tags_kw)
    date = fields.DateTimeField('Date', [validators.required()],
                                default=dt.datetime.now)
    modified = fields.HiddenField('Modified')
    slug = fields.StringField('Slug')
    language = fields.SmartSelect2Field(
        'Language',
        choices=lambda: [(lng, lng)
                         for lng in app.config.get('BABEL_LANGUAGES', ['en'])],
        default=get_default_language)
    # translations = fields.HiddenField('Translations')
    # todo: ^ create action 'add translation'
    published = fields.BooleanField('Status',
                                    render_kw={
                                        'data-toggle': "toggle",
                                        'data-on': "Published",
                                        'data-off': "Draft",
                                        "data-onstyle": 'success'
                                    })
    comments = fields.BooleanField('Comments',
                                   default=True,
                                   render_kw={
                                       'data-toggle': "toggle",
                                       'data-on': "Enabled",
                                       'data-off': "Disabled",
                                       "data-onstyle": 'success'
                                   })

    # to be used only for Block type
    block_items = InlineFieldList(InlineFormField(BlockItemForm),
                                  label='Items')

    custom_vars = InlineFieldList(InlineFormField(CustomVariablesForm),
                                  label='Custom Variables')
コード例 #9
0
class CreateContentForm(BaseContentForm):
    content_type = fields.SmartSelect2Field('Type',
                                            choices=lambda: [('a', 'a'),
                                                             ('b', 'b')])