コード例 #1
0
ファイル: test_blog.py プロジェクト: chrneumann/kotti_blog
    def test_blog_change_settings(self):
        settings = get_current_registry().settings
        settings['kotti_blog.blog_settings.use_batching'] = u'false'
        settings['kotti_blog.blog_settings.pagesize'] = u'2'
        settings['kotti_blog.blog_settings.use_auto_batching'] = u'false'
        settings['kotti_blog.blog_settings.link_headline_overview'] = u'false'

        b_settings = blog_settings()
        assert b_settings['use_batching'] == False
        assert b_settings['pagesize'] == 2
        assert b_settings['use_auto_batching'] == False
        assert b_settings['link_headline_overview'] == False
コード例 #2
0
ファイル: test_blog.py プロジェクト: chrneumann/kotti_blog
    def test_blog_wrong_settings(self):
        settings = get_current_registry().settings
        settings['kotti_blog.blog_settings.use_batching'] = u'blibs'
        settings['kotti_blog.blog_settings.pagesize'] = u'blabs'
        settings['kotti_blog.blog_settings.use_auto_batching'] = u'blubs'
        settings['kotti_blog.blog_settings.link_headline_overview'] = u'blobs'

        b_settings = blog_settings()
        assert b_settings['use_batching'] == False
        assert b_settings['pagesize'] == 5
        assert b_settings['use_auto_batching'] == False
        assert b_settings['link_headline_overview'] == False
コード例 #3
0
ファイル: views.py プロジェクト: cullerton/kotti_blog
 def view_blog(self):
     settings = blog_settings()
     macros = get_renderer('templates/macros.pt').implementation()
     session = DBSession()
     query = session.query(BlogEntry).filter(\
                 BlogEntry.parent_id == self.context.id).order_by(BlogEntry.date.desc())
     items = query.all()
     items = [item for item in items if has_permission('view', item, self.request)]
     page = self.request.params.get('page', 1)
     if settings['use_batching']:
         items = Batch.fromPagenumber(items,
                       pagesize=settings['pagesize'],
                       pagenumber=int(page))
     return {
         'api': template_api(self.context, self.request),
         'macros': macros,
         'items': items,
         'settings': settings,
         }
コード例 #4
0
ファイル: views.py プロジェクト: chrneumann/kotti_blog
def view_blog(context, request):
    settings = blog_settings()
    macros = get_renderer('templates/macros.pt').implementation()
    session = DBSession()
    query = session.query(BlogEntry).filter(\
                BlogEntry.parent_id == context.id).order_by(BlogEntry.date)
    items = query.all()
    page = request.params.get('page', 1)
    if settings['use_batching']:
        items = Batch.fromPagenumber(items,
                      pagesize=settings['pagesize'],
                      pagenumber=int(page))

    for item in items:
        item.formatted_date = format_date(item.date)

    return {
        'api': template_api(context, request),
        'macros': macros,
        'items': items,
        'settings': settings,
        }
コード例 #5
0
ファイル: test_blog.py プロジェクト: chrneumann/kotti_blog
 def test_blog_default_settings(self):
     b_settings = blog_settings()
     assert b_settings['use_batching'] == True
     assert b_settings['pagesize'] == 5
     assert b_settings['use_auto_batching'] == True
     assert b_settings['link_headline_overview'] == True