def feed(feed): query = Proposal.public() # FIXME: better sorting community = None if feed == "popular": query = query.order_by(-Proposal.ranking) community = Community(name="popular", description="The most popular posts on Pnyx.") elif feed == "upvote": query = query.order_by(-(Proposal.upvotes - Proposal.downvotes)) community = Community(name="upvote", description="The most upvoted posts on Pnyx.") elif feed == "new": query = query.order_by(Proposal.timestamp.desc()) community = Community( name="new", description=gettext("The newest posts from all of Pnyx. Come here " "to see posts rising and be a part of " "the conversation.")) else: query = query.order_by(-Proposal.ranking, Proposal.timestamp.desc()) return object_list('community.html', query, community=community, check_bounds=False)
def post_revisions(community, slug): query = Proposal.public() community = Community.get_or_none(Community.name == community) entry = get_object_or_404(query, Proposal.slug == slug, Proposal.community == community) return render_template('post_revisions.html', entry=entry, community=community)