]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/templatetags/node_tags.py
add an ability to attach extra classes to post controls - helps to reduce redundant...
[osqa.git] / forum / templatetags / node_tags.py
index 5cdd3b05d46aa1ef3a59edc5fbd5f76f9b6be0ed..aee496a8e4f2982f63c6d39679cdb36a542237e1 100644 (file)
@@ -77,9 +77,13 @@ def post_classes(post):
 \r
     return " ".join(classes)\r
 \r
-def post_control(text, url, command=False, withprompt=False, confirm=False, title="", copy=False):\r
+def post_control(text, url, command=False, withprompt=False, confirm=False, title="", copy=False, extra_classes=[]):\r
     classes = (command and "ajax-command" or " ") + (withprompt and " withprompt" or " ") + (confirm and " confirm" or " ") + \\r
         (copy and " copy" or " ")\r
+\r
+    for extra_class in extra_classes:\r
+        classes += " %s" % extra_class\r
+\r
     return {'text': text, 'url': url, 'classes': classes, 'title': title}\r
 \r
 \r
@@ -129,8 +133,16 @@ def post_controls(post, user):
             if user.can_view_offensive_flags(post):\r
                 label =  "%s (%d)" % (label, post.flag_count)\r
 \r
-            controls.append(post_control(label, reverse('flag_post', kwargs={'id': post.id}),\r
-                    command=True, withprompt=True, title=_("report as offensive (i.e containing spam, advertising, malicious text, etc.)")))\r
+\r
+            report_control = post_control(label, reverse('flag_post', kwargs={'id': post.id}),\r
+                    command=True, withprompt=True,\r
+                    title=_("report as offensive (i.e containing spam, advertising, malicious text, etc.)"))\r
+\r
+            # Depending on the setting choose where to attach the control\r
+            if settings.REPORT_OFFENSIVE_CONTROL_POSITION.value == "more":\r
+                menu.append(report_control)\r
+            else:\r
+                controls.append(report_control)\r
 \r
         if user.can_delete_post(post):\r
             if post.nis.deleted:\r
@@ -182,7 +194,8 @@ def post_controls(post, user):
 \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
@@ -233,6 +246,7 @@ def comments(post, user):
         '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