Esempio n. 1
0
class UseAutoPaginationSchemaNode(colander.SchemaNode):
    name = 'use_auto_pagination'
    title = _(u'Use auto pagination')
    description = _(u'Blog entries loaded automatically when scrolling '
                    u'down the blog page.')
    missing = False
    default = False
Esempio n. 2
0
class LinkHeadlineSchemaNode(colander.SchemaNode):
    name = 'link_headline'
    title = _(u'Link headline')
    description = _(u'Control whether the headline of a blog entry in '
                    u'the blog is linked to the blog entry.')
    missing = True
    default = True
Esempio n. 3
0
class BlogEntrySchema(DocumentSchema):
    date = colander.SchemaNode(
        colander.DateTime(),
        title=_(u'Date'),
        description=_(u'Choose date of the blog entry. '
                      u'If you leave this empty the creation date is used.'),
        validator=colander.Range(
            min=datetime.datetime(2012,
                                  1,
                                  1,
                                  0,
                                  0,
                                  tzinfo=colander.iso8601.Utc()),
            min_err=_('${val} is earlier than earliest datetime ${min}')),
        widget=DateTimeInputWidget(),
        missing=deferred_date_missing,
    )
Esempio n. 4
0
class Blog(Document):
    id = Column('id', Integer, ForeignKey('documents.id'), primary_key=True)

    type_info = Document.type_info.copy(
        name=u'Blog',
        title=_(u'Blog'),
        add_view=u'add_blog',
        addable_to=[u'Document'],
    )
Esempio n. 5
0
class BlogEntry(Document):
    id = Column(Integer, ForeignKey('documents.id'), primary_key=True)
    date = Column('date', UTCDateTime())

    type_info = Document.type_info.copy(
        name=u'Blog entry',
        title=_(u'Blog entry'),
        add_view=u'add_blogentry',
        addable_to=[u'Blog'],
    )

    def __init__(self, date=None, **kwargs):
        super(BlogEntry, self).__init__(**kwargs)
        self.date = date
Esempio n. 6
0
class BlogEntryAddForm(AddFormView):
    schema_factory = BlogEntrySchema
    add = BlogEntry
    item_type = _(u"Blog Entry")
Esempio n. 7
0
class BlogAddForm(AddFormView):
    schema_factory = BlogSchema
    add = Blog
    item_type = _(u"Blog")
Esempio n. 8
0
class UsePaginationSchemaNode(colander.SchemaNode):
    name = 'use_pagination'
    title = _(u'Use pagination')
    description = _(u'Use pagination for entries on the blog.')
    missing = True
    default = True
Esempio n. 9
0
class PagesizeSchemaNode(colander.SchemaNode):
    name = 'pagesize'
    title = _(u'Page size')
    description = _(u'Choose how many blog entries are shown ' u'on one page.')
    default = 5
Esempio n. 10
0
    default = False


class LinkHeadlineSchemaNode(colander.SchemaNode):
    name = 'link_headline'
    title = _(u'Link headline')
    description = _(u'Control whether the headline of a blog entry in '
                    u'the blog is linked to the blog entry.')
    missing = True
    default = True


class KottiBlogSettingsSchema(colander.MappingSchema):
    use_pagination = UsePaginationSchemaNode(colander.Boolean())
    pagesize = PagesizeSchemaNode(colander.Integer())
    use_auto_pagination = UseAutoPaginationSchemaNode(colander.Boolean())
    link_headline = LinkHeadlineSchemaNode(colander.Boolean())


KottiBlogSettings = {
    'name': 'kotti_blog_settings',
    'title': _(u'Blog settings'),
    'description': _(u"Settings for kotti_blog"),
    'success_message': _(u"Successfully saved blog settings."),
    'schema_factory': KottiBlogSettingsSchema,
}


def populate_settings():
    add_settings(KottiBlogSettings)
Esempio n. 11
0
    default = False


class LinkHeadlineSchemaNode(colander.SchemaNode):
    name = 'link_headline'
    title = _(u'Link headline')
    description = _(u'Control whether the headline of a blog entry in '
                    u'the blog is linked to the blog entry.')
    missing = True
    default = True


class KottiBlogSettingsSchema(colander.MappingSchema):
    use_pagination = UsePaginationSchemaNode(colander.Boolean())
    pagesize = PagesizeSchemaNode(colander.Integer())
    use_auto_pagination = UseAutoPaginationSchemaNode(colander.Boolean())
    link_headline = LinkHeadlineSchemaNode(colander.Boolean())


KottiBlogSettings = {
    'name': 'kotti_blog_settings',
    'title': _(u'Blog settings'),
    'description': _(u"Settings for kotti_blog"),
    'success_message': _(u"Successfully saved blog settings."),
    'schema_factory': KottiBlogSettingsSchema,
}


def populate_settings():
    add_settings(KottiBlogSettings)