* Enable threaded comments for influences.
authorMatthijs Kooijman <matthijs@stdin.nl>
Sat, 26 Jul 2008 11:09:20 +0000 (13:09 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Sat, 26 Jul 2008 11:09:20 +0000 (13:09 +0200)
influences/views.py
templates/influences/influence_detail_block.html

index fec38f31f225f76ab741dbf802ed70e15938c998..ea07c70c03f86c668562ced31549d3673d8bd72c 100644 (file)
@@ -7,6 +7,8 @@ from django.contrib.auth.models import User
 from django.core.urlresolvers import reverse
 from django.http import HttpResponseRedirect, HttpResponseForbidden
 from django.views.generic.list_detail import object_detail, object_list
+from threadedcomments.models import ThreadedComment
+from threadedcomments.forms import ThreadedCommentForm
 from xerxes.influences.models import Character
 from xerxes.influences.models import Influence
 from xerxes.tools.forms import ContextModelForm
@@ -103,6 +105,11 @@ def influence_detail(request, object_id):
     # Don't show other player's influences
     if (o.character.player != request.user):
         return HttpResponseForbidden("Forbidden -- Trying to view influences of somebody else's character")
-    return render_to_response('influences/influence_detail.html', {'object' : o}, RequestContext(request))
+    context  = {
+        'object' : o,
+        'comments' : ThreadedComment.public.get_tree(o),
+        'comment_form' : ThreadedCommentForm(),
+    }
+    return render_to_response('influences/influence_detail.html', context, RequestContext(request))
 
 # vim: set sts=4 sw=4 expandtab:
index d2c1c3ae9dee48b13ad88a86490f52826aaf0ff7..cc78c47fb7491019e18c4b1b4d75d914740cbbe2 100644 (file)
@@ -1,4 +1,5 @@
 {% load i18n %}
+{% load threadedcommentstags %}
 
 <h1>{{ object.summary }}</h1>
 <table>
@@ -9,3 +10,55 @@
 {% endif %}
 </table>
 <p>{{ object.description }}</p>
+<script>
+       function showReply(comment_id) {
+               YAHOO.util.Dom.setStyle('replyForm' + comment_id, 'display', 'block');
+               YAHOO.util.Dom.setStyle('replyLink' + comment_id, 'display', 'none');
+       }
+
+       function hideReply(comment_id) {
+               YAHOO.util.Dom.setStyle('replyForm' + comment_id, 'display', 'none');
+               YAHOO.util.Dom.setStyle('replyLink' + comment_id, 'display', 'block');
+       }
+</script>
+               
+<h2>{% trans "Comments" %}</h2>
+{% if comments %}
+    {% for comment in comments %}
+        <div style="margin-left: {{ comment.depth }}em;" class="comment">
+            {{ comment.user }} said:<br/>
+            {% auto_transform_markup comment %}
+                       <p style="display:none;" id="replyLink{{comment.id}}"><a href="javascript:showReply('{{comment.id}}');">Reply to this comment</a></p>
+                       <div id="replyForm{{comment.id}}" class="commentReplyForm">
+                               <script>hideReply('{{comment.id}}');</script>
+                               <form method="POST" action="{% get_comment_url object comment %}">
+                                       <p><a href="javascript:hideReply('{{comment.id}}');">Cancel reply</a></p>
+                                       <ul>
+                                               <table>
+                                               {{ comment.get_reply_form.as_table }}
+                                               </table>
+                                               <input type="submit" value="{% trans "Reply to this comment" %}" /></li>
+                                       </ul>
+                               </form>
+                       </div>
+        </div>
+    {% endfor %}
+{% else %}
+    {% trans "No comments were added yet" %}
+{% endif %}
+
+<p style="display:none;" id="replyLink"><a href="javascript:showReply('')">Add comment</a></p>
+<div id="replyForm">
+<script>hideReply('')</script>
+<h3>{% trans "Add comment" %}<h3>
+<form method="POST" action="{% get_comment_url object %}">
+       <p><a href="javascript:hideReply('')">Cancel comment</a></p>
+    <ul>
+        <table>
+        {{ comment_form.as_table }}
+        </table>
+        <input type="submit" value="{% trans "Add comment" %}" /></li>
+        <input type="submit" name="preview" value="{% trans "Preview comment" %}" /></li>
+    </ul>
+</form>
+</div>