Adam Knight avatar Adam Knight committed 3b73c66

Work on comments

Comments (0)

Files changed (6)

comments/admin.py

+from django.contrib import admin
+import models
+
+class MPTTCommentAdmin(admin.ModelAdmin):
+    pass
+
+admin.site.register(models.MPTTComment, MPTTCommentAdmin);

comments/models.py

 from django.contrib.comments.models import Comment
 from mptt.models import MPTTModel, TreeForeignKey
 
-
 ### COMMENTS ###
 
 class MPTTComment(MPTTModel, Comment):
 
     class Meta:
         ordering=['tree_id','lft']
+
+    @property
+    def depth(self):
+        return self.get_ancestors().count()

comments/templates/comments.html

 
 {% if comments %}
 {% recursetree comments %}
-            <a name="c{{ node.id }}"></a>
-            {{ node.comment }}
-            {{ node.user }}
-            {{ node.submit_date|timesince }} ago
-            <a href="{{ object.get_absolute_url }}#c{{ node.id }}">#</a>
-        {% render_comment_form for object %}
-
+    {% with node as comment %}
+    {% include "comment.html" %}
+    {% endwith %}
     {# recursion! children of a given comment #}
     {% if not node.is_leaf_node %}
         {{ children }}

comments/templates/comments/form.html

+{% load comments i18n %}
+<form action="{% comment_form_target %}" method="post">{% csrf_token %}
+  {% if next %}<div><input type="hidden" name="next" value="{{ next }}" /></div>{% endif %}
+  {% for field in form %}
+    {% if field.is_hidden %}
+      <div>{{ field }}</div>
+    {% else %}
+      {% if field.errors %}{{ field.errors }}{% endif %}
+      <p
+        {% if field.errors %} class="error"{% endif %}
+        {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
+        {{ field.label_tag }} {{ field }}
+      </p>
+    {% endif %}
+  {% endfor %}
+  Something
+  {% if object.id %}
+  Something
+      <input type="hidden" name="parent" id="parent_id" value="{{ object.id }}" />
+  {% endif %}
+  <p class="submit">
+    <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
+    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
+  </p>
+</form>

comments/templates/form.html

-{% load comments i18n %}
-<form action="{% comment_form_target %}" method="post">{% csrf_token %}
-  {% if next %}<div><input type="hidden" name="next" value="{{ next }}" /></div>{% endif %}
-  {% for field in form %}
-    {% if field.is_hidden %}
-      <div>{{ field }}</div>
-    {% else %}
-      {% if field.errors %}{{ field.errors }}{% endif %}
-      <p
-        {% if field.errors %} class="error"{% endif %}
-        {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
-        {{ field.label_tag }} {{ field }}
-      </p>
-    {% endif %}
-  {% endfor %}
-  {% if node.id %}    
-      <input type="hidden" name="parent" id="parent_id" value="{{ node.id }}" />
-  {% endif %}
-  <p class="submit">
-    <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
-    <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
-  </p>
-</form>
     # Prepare the template data
     context = {
         "title":  story.title,
-        "object": story
+        "object": story,
+        "next": story.get_absolute_url()
     }
     
     response = render_to_response("story_detail.html", context, context_instance=RequestContext(request))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.