diff --git a/isso/css/admin.css b/isso/css/admin.css index d6a8f74..5a434fc 100644 --- a/isso/css/admin.css +++ b/isso/css/admin.css @@ -116,3 +116,10 @@ a { .isso-comment-footer a { cursor: pointer; } +.thread-title { + margin-left: 3em; +} +.group { + float: left; + margin-left: 2em; +} diff --git a/isso/db/comments.py b/isso/db/comments.py index 69790ac..62cfad2 100644 --- a/isso/db/comments.py +++ b/isso/db/comments.py @@ -137,10 +137,10 @@ class Comments: sql_args.append(parent) # custom sanitization - if order_by not in ['id', 'created', 'modified', 'likes', 'dislikes']: + if order_by not in ['id', 'created', 'modified', 'likes', 'dislikes', 'tid']: order_by = 'id' sql.append('ORDER BY ') - sql.append('comments.' + order_by) + sql.append('comments.' + order_by + ", comments.created") sql.append(' DESC') if limit: diff --git a/isso/templates/admin.html b/isso/templates/admin.html index c32ff1e..9d10816 100644 --- a/isso/templates/admin.html +++ b/isso/templates/admin.html @@ -77,6 +77,9 @@ function delete_com(com_id, hash) { +
+ Group by thread: +
+ {% set thread_id = "no_id" %} {% for comment in comments %} + {% if order_by == "tid" %} + {% if thread_id != comment.tid %} + {% set thread_id = comment.tid %} +

{{comment.title}}

+ {% endif %} + {% endif %}
{% if conf.avatar %}
@@ -103,6 +113,9 @@ function delete_com(com_id, hash) { {% endif %}
+ {% if order_by != "tid" %} + Thread: {{comment.title}}
+ {% endif %} {% if comment.author %} {{comment.author}} {% else %} diff --git a/isso/views/comments.py b/isso/views/comments.py index 68c228f..df1eebe 100644 --- a/isso/views/comments.py +++ b/isso/views/comments.py @@ -520,9 +520,11 @@ class API(object): return render_template('login.html') page_size = 100 page = req.args.get('page', 0) + order_by = req.args.get('order_by', "id") mode = req.args.get('mode', 2) comments = self.comments.fetchall(mode=mode, page=page, - limit=page_size) + limit=page_size, + order_by=order_by) comments_enriched = [] for comment in list(comments): comment['hash'] = self.isso.sign(comment['id']) @@ -532,4 +534,5 @@ class API(object): return render_template('admin.html', comments=comments_enriched, page=int(page), mode=int(mode), conf=self.conf, max_page=max_page, - counts=comment_mode_count) + counts=comment_mode_count, + order_by=order_by)