コード例 #1
0
ファイル: formats.py プロジェクト: www3838438/quokka_ng
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')
コード例 #2
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'
                                    })
コード例 #3
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')
コード例 #4
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'
                                    })
コード例 #5
0
class BaseContentForm(Form):
    """Base form for all contents"""

    title = fields.StringField('Title', [validators.required()])
    summary = fields.TextAreaField('Summary')
    category = fields.Select2TagsField('Category', save_as_list=False)
    tags = fields.Select2TagsField('Tags', save_as_list=True)
    authors = fields.Select2TagsField('Authors', save_as_list=True)
    date = fields.DateTimeField('Date')
    modified = fields.HiddenField('Modified')
コード例 #6
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')