def topics(): qb = QueryBuilder(request.args) qb.setSortIfNone("date") query = qb.buildTopicQuery() tmp_q = ForumTopic.query if not qb.show_discarded: tmp_q = tmp_q.filter_by(discarded=False) total = tmp_q.count() topic_count = query.count() page = get_int_or_abort(request.args.get("page"), 1) num = get_int_or_abort(request.args.get("n"), 100) if num > 100 and not current_user.rank.atLeast(UserRank.EDITOR): num = 100 query = query.paginate(page, num, True) next_url = url_for("todo.topics", page=query.next_num, query=qb.search, \ show_discarded=qb.show_discarded, n=num, sort=qb.order_by) \ if query.has_next else None prev_url = url_for("todo.topics", page=query.prev_num, query=qb.search, \ show_discarded=qb.show_discarded, n=num, sort=qb.order_by) \ if query.has_prev else None return render_template("todo/topics.html", topics=query.items, total=total, \ topic_count=topic_count, query=qb.search, show_discarded=qb.show_discarded, \ next_url=next_url, prev_url=prev_url, page=page, page_max=query.pages, \ n=num, sort_by=qb.order_by)
def tags(): qb = QueryBuilder(request.args) qb.setSortIfNone("score", "desc") query = qb.buildPackageQuery() tags = Tag.query.order_by(db.asc(Tag.title)).all() return render_template("todo/tags.html", packages=query.all(), tags=tags)
def tags(): qb = QueryBuilder(request.args) qb.setSortIfNone("score", "desc") query = qb.buildPackageQuery() only_no_tags = isYes(request.args.get("no_tags")) if only_no_tags: query = query.filter(Package.tags == None) tags = Tag.query.order_by(db.asc(Tag.title)).all() return render_template("todo/tags.html", current_tab="tags", packages=query.all(), \ tags=tags, only_no_tags=only_no_tags)