diff --git a/app/templates/todo/topics.html b/app/templates/todo/topics.html
index 74a9381..4236a40 100644
--- a/app/templates/todo/topics.html
+++ b/app/templates/todo/topics.html
@@ -8,10 +8,32 @@ Topics to be Added
Topics to be Added
- {{ total - (topics | count) }} / {{ total }} packages have been added.
+ {{ total - (topic_count) }} / {{ total }} packages have been added.
{{ topics | count }} remaining.
+
+
{% from "macros/topics.html" import render_topics_table %}
{{ render_topics_table(topics) }}
+
+
{% endblock %}
diff --git a/app/views/packages/todo.py b/app/views/packages/todo.py
index 746ca61..596e83a 100644
--- a/app/views/packages/todo.py
+++ b/app/views/packages/todo.py
@@ -56,9 +56,24 @@ def todo_page():
def todo_topics_page():
total = ForumTopic.query.count()
- topics = ForumTopic.query \
+ query = ForumTopic.query \
.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
- .order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \
- .all()
+ .order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
- return render_template("todo/topics.html", topics=topics, total=total)
+ topic_count = query.count()
+
+ search = request.args.get("q")
+ if search is not None and search.strip() != "":
+ query = query.filter(ForumTopic.title.ilike('%' + search + '%'))
+
+ page = int(request.args.get("page") or 1)
+ num = min(100, int(request.args.get("n") or 100))
+ query = query.paginate(page, num, True)
+ next_url = url_for("todo_topics_page", page=query.next_num) \
+ if query.has_next else None
+ prev_url = url_for("todo_topics_page", page=query.prev_num) \
+ if query.has_prev else None
+
+ return render_template("todo/topics.html", topics=query.items, total=total, \
+ topic_count=topic_count, query=search, \
+ next_url=next_url, prev_url=prev_url, page=page, page_max=query.pages)