]> git.openstreetmap.org Git - osqa.git/commitdiff
adding a setting that allows the users to choose the comments order
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 24 Oct 2011 22:14:16 +0000 (22:14 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Mon, 24 Oct 2011 22:14:16 +0000 (22:14 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1194 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/settings/view.py
forum/skins/default/templates/node/comment_skeleton.html [new file with mode: 0644]
forum/skins/default/templates/node/comments.html
forum/templatetags/node_tags.py

index 9b7cf4ea00619f03aa26ae10aaf9a0a83ed0abca..b87c33c5c4be44835cf19ddadd78f3e478682db9 100644 (file)
@@ -9,6 +9,12 @@ label = _("Embed YouTube Videos"),
 help_text = _("If you check this YouTube videos will be embedded"),
 required=False))
 
 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.")))
 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 (file)
index 0000000..c9f95e1
--- /dev/null
@@ -0,0 +1,60 @@
+{% load extra_tags %}
+{% load i18n %}
+
+<div class="clear"></div>
+<div id="comment-{{ post.id }}-form-container" class="comment-form-container">
+    {% if can_comment %}
+    <form id="comment-{{ post.id }}-form" method="post" action="{% url comment id=post.id %}" accept-charset="utf-8">
+        {% csrf_token %}
+        <div class="comment-form-widgets-container">
+            <textarea name="comment" class="commentBox" id="comment"></textarea>
+            <div class="comment-form-buttons">
+                <span id="comment-{{ post.id }}-chars-left" class="comment-chars-left">
+                    <span class="comments-char-left-count">{{ min_length }}|{{ max_length }}</span>
+                    <span class="comments-chars-togo-msg">{% trans "characters needed" %}</span>
+                    <span class="comments-chars-left-msg">{% trans "characters left" %}</span>
+                </span>
+                <input type="submit" class="comment-submit" value="{% trans " comment" %}" />
+                <input type="submit" class="comment-cancel" value="{% trans " cancel" %}" />
+            </div>
+            <div class="clear"></div>
+            {% if user.can_use_canned_comments %}
+            <div class="canned_comment">
+                <span id="post-{{ post.id }}-menu" class="context-menu">
+                    <span id="post-{{ post.id }}-menu-trigger" class="action-link context-menu-trigger">{% trans "Use canned comment" %}</span>
+                    <ul id="post-{{ post.id }}-menu-dropdown" class="context-menu-dropdown" style="width: 275px;">
+                        {% for canned_comment in canned_comments %}
+                        <li class="item">
+                            <a style="white-space: pre-wrap;" href="javascript:void(0);" onclick="canned_comment({{ post.id }}, jQuery(this).text())">{{ canned_comment }}</a>
+                        </li>
+                        {% endfor %}
+                    </ul>
+                </span>
+            </div>
+            {% endif %}
+        </div>
+        <script type="text/html" class="new-comment-skeleton" id="new-comment-skeleton-{{ post.id }}">
+            <div class="comment{% if not comment.top_scorer %} not_top_scorer{% endif %}" id="comment-%ID%">
+                <div id="post-%ID%-score" class="comment-score"></div>
+                <div class="comment-text">%COMMENT%</div>
+                <div class="comment-info" id="comment-%ID%-info">
+                    <a id="comment-%ID%-edit" href="%EDIT_URL%" title="{% trans "Edit comment" %}"
+                        class="comment-edit" rel="nofollow"> </a>
+                    <a id="comment-%ID%-delete" href="%DELETE_URL%" title="{% trans "Delete comment" %}"
+                        class="ajax-command comment-delete confirm" rel="nofollow"> </a>
+                    <a rel="nofollow" id="comment-%ID%-convert" style="display:none;" href="%CONVERT_URL%" title="{% trans "Convert comment to answer" %}"
+                        class="ajax-command comment-convert confirm" rel="nofollow"> </a>
+
+                    <span class="comment-age">({% trans "just now" %})</span>
+                    <a class="comment-user" href="%PROFILE_URL%">%USERNAME%</a>
+                    {% if user.is_authenticated %}
+                        {% if show_gravatar %}{% gravatar user 18 %}{% endif %}
+                    {% endif %}
+                </div>
+             </div>
+        </script>
+    </form>
+    {% endif %}
+</div>
+<div class="clear"></div>
+
index 3457aab60491aa5b8a9bafc755b89a5bfa4a4bd4..b34b58d8d8ac6b113aecf236d8889f61ece00528 100644 (file)
@@ -1,62 +1,7 @@
 {% load extra_tags %}\r
 {% load i18n %}\r
 \r
 {% load extra_tags %}\r
 {% load i18n %}\r
 \r
-<div class="clear"></div>\r
-<div id="comment-{{ post.id }}-form-container" class="comment-form-container">\r
-    {% if can_comment %}\r
-    <form id="comment-{{ post.id }}-form" method="post" action="{% url comment id=post.id %}" accept-charset="utf-8">\r
-        {% csrf_token %}\r
-        <div class="comment-form-widgets-container">\r
-            <textarea name="comment" class="commentBox" id="comment"></textarea>\r
-            <div class="comment-form-buttons">\r
-                <span id="comment-{{ post.id }}-chars-left" class="comment-chars-left">\r
-                    <span class="comments-char-left-count">{{ min_length }}|{{ max_length }}</span>\r
-                    <span class="comments-chars-togo-msg">{% trans "characters needed" %}</span>\r
-                    <span class="comments-chars-left-msg">{% trans "characters left" %}</span>\r
-                </span>\r
-                <input type="submit" class="comment-submit" value="{% trans " comment" %}" />\r
-                <input type="submit" class="comment-cancel" value="{% trans " cancel" %}" />\r
-            </div>\r
-            <div class="clear"></div>\r
-            {% if user.can_use_canned_comments %}\r
-            <div class="canned_comment">\r
-                <span id="post-{{ post.id }}-menu" class="context-menu">\r
-                    <span id="post-{{ post.id }}-menu-trigger" class="action-link context-menu-trigger">{% trans "Use canned comment" %}</span>\r
-                    <ul id="post-{{ post.id }}-menu-dropdown" class="context-menu-dropdown" style="width: 275px;">\r
-                        {% for canned_comment in canned_comments %}\r
-                        <li class="item">\r
-                            <a style="white-space: pre-wrap;" href="javascript:void(0);" onclick="canned_comment({{ post.id }}, jQuery(this).text())">{{ canned_comment }}</a>\r
-                        </li>\r
-                        {% endfor %}\r
-                    </ul>\r
-                </span>\r
-            </div>\r
-            {% endif %}\r
-        </div>\r
-        <script type="text/html" class="new-comment-skeleton" id="new-comment-skeleton-{{ post.id }}">\r
-            <div class="comment{% if not comment.top_scorer %} not_top_scorer{% endif %}" id="comment-%ID%">\r
-                <div id="post-%ID%-score" class="comment-score"></div>\r
-                <div class="comment-text">%COMMENT%</div>\r
-                <div class="comment-info" id="comment-%ID%-info">\r
-                    <a id="comment-%ID%-edit" href="%EDIT_URL%" title="{% trans "Edit comment" %}"\r
-                        class="comment-edit" rel="nofollow"> </a>\r
-                    <a id="comment-%ID%-delete" href="%DELETE_URL%" title="{% trans "Delete comment" %}"\r
-                        class="ajax-command comment-delete confirm" rel="nofollow"> </a>\r
-                    <a rel="nofollow" id="comment-%ID%-convert" style="display:none;" href="%CONVERT_URL%" title="{% trans "Convert comment to answer" %}"\r
-                        class="ajax-command comment-convert confirm" rel="nofollow"> </a>\r
-\r
-                    <span class="comment-age">({% trans "just now" %})</span>\r
-                    <a class="comment-user" href="%PROFILE_URL%">%USERNAME%</a>\r
-                    {% if user.is_authenticated %}\r
-                        {% if show_gravatar %}{% gravatar user 18 %}{% endif %}\r
-                    {% endif %}\r
-                </div>\r
-             </div>\r
-        </script>\r
-    </form>\r
-    {% endif %}\r
-</div>\r
-<div class="clear"></div>\r
+{% if show_latest_comments_first %}{% include "node/comment_skeleton.html" %}{% endif %}\r
 \r
 <div class="comments-container" id="comments-container-{{ post.id }}">\r
     {% for comment in comments %}\r
 \r
 <div class="comments-container" id="comments-container-{{ post.id }}">\r
     {% for comment in comments %}\r
         <a href="#" class="add-comment-link">{% trans "add new comment" %}</a>\r
     {% endif %}\r
 </div>\r
         <a href="#" class="add-comment-link">{% trans "add new comment" %}</a>\r
     {% endif %}\r
 </div>\r
+\r
+{% if not show_latest_comments_first %}{% include "node/comment_skeleton.html" %}{% endif %}\r
index 5cdd3b05d46aa1ef3a59edc5fbd5f76f9b6be0ed..69260c4a8e2f4bcaa7876747a6e9251686179dcb 100644 (file)
@@ -182,7 +182,8 @@ def post_controls(post, user):
 \r
 @register.inclusion_tag('node/comments.html')\r
 def comments(post, user):\r
 \r
 @register.inclusion_tag('node/comments.html')\r
 def comments(post, user):\r
-    all_comments = post.comments.filter_state(deleted=False).order_by('-added_at')\r
+    all_comments = post.comments.filter_state(deleted=False)\\r
+                                .order_by('-added_at' if settings.SHOW_LATEST_COMMENTS_FIRST else 'added_at')\r
 \r
     if len(all_comments) <= 5:\r
         top_scorers = all_comments\r
 \r
     if len(all_comments) <= 5:\r
         top_scorers = all_comments\r
@@ -233,6 +234,7 @@ def comments(post, user):
         'showing': showing,\r
         'total': total,\r
         'more_comments_count' : int(total - showing),\r
         'showing': showing,\r
         'total': total,\r
         'more_comments_count' : int(total - showing),\r
+        'show_latest_comments_first' : settings.SHOW_LATEST_COMMENTS_FIRST,\r
         'user': user,\r
     }\r
 \r
         'user': user,\r
     }\r
 \r