From 158a305095187b1b1c9cee417b94d15f515e5ebe Mon Sep 17 00:00:00 2001 From: jordan Date: Mon, 24 Oct 2011 22:14:16 +0000 Subject: [PATCH] adding a setting that allows the users to choose the comments order git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1194 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/settings/view.py | 6 ++ .../templates/node/comment_skeleton.html | 60 +++++++++++++++++++ .../default/templates/node/comments.html | 59 +----------------- forum/templatetags/node_tags.py | 4 +- 4 files changed, 72 insertions(+), 57 deletions(-) create mode 100644 forum/skins/default/templates/node/comment_skeleton.html diff --git a/forum/settings/view.py b/forum/settings/view.py index 9b7cf4e..b87c33c 100644 --- a/forum/settings/view.py +++ b/forum/settings/view.py @@ -9,6 +9,12 @@ label = _("Embed YouTube Videos"), help_text = _("If you check this YouTube videos will be embedded"), required=False)) +SHOW_LATEST_COMMENTS_FIRST = Setting('SHOW_LATEST_COMMENTS_FIRST', False, VIEW_SET, dict( +label = _("Show latest comments first"), +help_text = _("Choose this if you want the latest comments to appear first."), +required=False)) + + SUMMARY_LENGTH = Setting('SUMMARY_LENGTH', 300, VIEW_SET, dict( label = _("Summary Length"), help_text = _("The number of characters that are going to be displayed in order to get the content summary."))) diff --git a/forum/skins/default/templates/node/comment_skeleton.html b/forum/skins/default/templates/node/comment_skeleton.html new file mode 100644 index 0000000..c9f95e1 --- /dev/null +++ b/forum/skins/default/templates/node/comment_skeleton.html @@ -0,0 +1,60 @@ +{% load extra_tags %} +{% load i18n %} + +
+
+ {% if can_comment %} +
+ {% csrf_token %} +
+ +
+ + {{ min_length }}|{{ max_length }} + {% trans "characters needed" %} + {% trans "characters left" %} + + + +
+
+ {% if user.can_use_canned_comments %} +
+ + {% trans "Use canned comment" %} + + +
+ {% endif %} +
+ +
+ {% endif %} +
+
+ diff --git a/forum/skins/default/templates/node/comments.html b/forum/skins/default/templates/node/comments.html index 3457aab..b34b58d 100644 --- a/forum/skins/default/templates/node/comments.html +++ b/forum/skins/default/templates/node/comments.html @@ -1,62 +1,7 @@ {% load extra_tags %} {% load i18n %} -
-
- {% if can_comment %} -
- {% csrf_token %} -
- -
- - {{ min_length }}|{{ max_length }} - {% trans "characters needed" %} - {% trans "characters left" %} - - - -
-
- {% if user.can_use_canned_comments %} -
- - {% trans "Use canned comment" %} - - -
- {% endif %} -
- -
- {% endif %} -
-
+{% if show_latest_comments_first %}{% include "node/comment_skeleton.html" %}{% endif %}
{% for comment in comments %} @@ -104,3 +49,5 @@ {% trans "add new comment" %} {% endif %}
+ +{% if not show_latest_comments_first %}{% include "node/comment_skeleton.html" %}{% endif %} diff --git a/forum/templatetags/node_tags.py b/forum/templatetags/node_tags.py index 5cdd3b0..69260c4 100644 --- a/forum/templatetags/node_tags.py +++ b/forum/templatetags/node_tags.py @@ -182,7 +182,8 @@ def post_controls(post, user): @register.inclusion_tag('node/comments.html') def comments(post, user): - all_comments = post.comments.filter_state(deleted=False).order_by('-added_at') + all_comments = post.comments.filter_state(deleted=False)\ + .order_by('-added_at' if settings.SHOW_LATEST_COMMENTS_FIRST else 'added_at') if len(all_comments) <= 5: top_scorers = all_comments @@ -233,6 +234,7 @@ def comments(post, user): 'showing': showing, 'total': total, 'more_comments_count' : int(total - showing), + 'show_latest_comments_first' : settings.SHOW_LATEST_COMMENTS_FIRST, 'user': user, } -- 2.39.5