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
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 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, )
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'], )
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
class BlogEntryAddForm(AddFormView): schema_factory = BlogEntrySchema add = BlogEntry item_type = _(u"Blog Entry")
class BlogAddForm(AddFormView): schema_factory = BlogSchema add = Blog item_type = _(u"Blog")
class UsePaginationSchemaNode(colander.SchemaNode): name = 'use_pagination' title = _(u'Use pagination') description = _(u'Use pagination for entries on the blog.') missing = True default = True
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
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)