Anonymous avatar Anonymous committed 297cc69

Fixed #154 for real.

Comments (0)

Files changed (2)

         return [x for x in self.comments if x.parent is None]
 
     @property
+    def visible_comments(self):
+        """Return only the comments for this post that are visible to
+        the user.
+        """
+        return [x for x in self.comments if x.visible]
+
+    @property
+    def visible_root_comments(self):
+        """Return only the comments for this post that are visible to
+        the user and that don't have a parent.
+        """
+        return [x for x in self.comments if x.visible and x.parent is None]
+
+    @property
     def comment_count(self):
         """The number of visible comments."""
         req = get_request()

zine/templates/_comment.html

 {% macro render_comments(post) %}
   {%- if cfg.use_flat_comments %}
     <ol id="comments">
-    {%- for comment in post.comments %}
-      {%- if comment.visible %}
+    {%- for comment in post.visible_comments %}
       <li class="comment">{{ render_comment(comment) }}</li>
-      {%- endif %}
+    {%- else %}
+      {# invisble LI to make validators happy.  We do not omit the
+         list itself because javascript might still want to reference it. #}
+      <li style="display: none"></li>
     {%- endfor %}
     </ol>
   {%- else %}
     <ul id="comments">
-    {%- for comment in post.root_comments recursive %}
-      {%- if comment.visible or comment.children %}
+    {%- for comment in post.visible_root_comments recursive %}
       <li class="comment">
-      {%- if comment.visible %}
-      {{ render_comment(comment, post.comments_enabled and not cfg.use_flat_comments) }}
-      {%- endif %}
-      {%- if comment.children %}
-      <ul class="sub_comments">{{ loop(comment.children) }}</ul>
-      {%- endif %}
+        {{ render_comment(comment, post.comments_enabled) }}
+        {%- if comment.children %}
+          <ul class="sub_comments">{{ loop(comment.children) }}</ul>
+        {%- endif %}
       </li>
-      {%- endif %}
+    {%- else %}
+      {# invisble LI to make validators happy.  We do not omit the
+         list itself because javascript might still want to reference it. #}
+      <li style="display: none"></li>
     {%- endfor %}
     </ul>
   {%- endif %}
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.