def topic(request, tag): qs = Post.pub() rqs = Post.rpub() if tag is not None: qs = qs.filter('topics = ', tag) rqs = rqs.filter('topics = ', tag) prev, posts, next = pager(qs, lambda bm: qs.filter('sort_key <', bm), lambda bm: rqs.filter('sort_key >', bm), bookmark=request.args.get('bookmark', None)) ns = NutSettings() template = ns.archive_layout if template: template = 'nut:layout/%s' % template else: template = 'app:articles/archive.html' return render_template(template, prev=prev, next=next, posts = posts, tag=tag)
def list(request): from logging import info from datetime import datetime if request.method == 'POST': handle_backup(request.files.get('backup')) pub_bm, upc_bm, unp_bm = None, None, None if request.args.get('list','') == 'published': pub_bm = request.args.get('bookmark', None) elif request.args.get('list','') == 'upcoming': upc_bm = request.args.get('bookmark', None) elif request.args.get('list','') == 'unpublished': unp_bm = request.args.get('bookmark', None) pub_prev, pub, pub_next = pager(Post.pub(), lambda bm: Post.pub().filter('sort_key <', bm), lambda bm: Post.rpub().filter('sort_key >', bm), bookmark=pub_bm) upc_prev, upc, upc_next = pager(Post.upcoming(), lambda bm: Post.upcoming()\ .filter('sort_key <', bm), lambda bm: Post.rupcoming()\ .filter('sort_key >', bm), bookmark=upc_bm) unp_prev, unp, unp_next = pager(Post.unpub(), lambda bm: Post.unpub()\ .filter('sort_key <', bm), lambda bm: Post.runpub()\ .filter('sort_key >', bm), bookmark=unp_bm) return render_template('app:articles/list.html', unpublished_prev = unp_prev, unpublished = unp, unpublished_next = unp_next, upcoming_prev = upc_prev, upcoming = upc, upcoming_next = upc_next, published_prev = pub_prev, published = pub, published_next = pub_next)