Show More
@@ -58,6 +58,7 b' POST_VIEW_PARAMS = (' | |||||
58 | 'truncated', |
|
58 | 'truncated', | |
59 | 'mode_tree', |
|
59 | 'mode_tree', | |
60 | 'perms', |
|
60 | 'perms', | |
|
61 | 'tree_depth', | |||
61 | ) |
|
62 | ) | |
62 |
|
63 | |||
63 |
|
64 |
@@ -279,3 +279,20 b' class Thread(models.Model):' | |||||
279 | if len(parents) > 0: |
|
279 | if len(parents) > 0: | |
280 | self.tags.add(*parents) |
|
280 | self.tags.add(*parents) | |
281 |
|
281 | |||
|
282 | def get_reply_tree(self): | |||
|
283 | replies = self.get_replies().prefetch_related('refposts') | |||
|
284 | tree = [] | |||
|
285 | for reply in replies: | |||
|
286 | parents = reply.refposts.all() | |||
|
287 | found_parent = False | |||
|
288 | if len(parents) > 0: | |||
|
289 | index = 0 | |||
|
290 | for depth, element in tree: | |||
|
291 | index += 1 | |||
|
292 | if element in parents: | |||
|
293 | tree.insert(index, (depth + 1, reply)) | |||
|
294 | found_parent = True | |||
|
295 | if not found_parent: | |||
|
296 | tree.append((0, reply)) | |||
|
297 | ||||
|
298 | return tree |
@@ -3,7 +3,7 b'' | |||||
3 |
|
3 | |||
4 | {% get_current_language as LANGUAGE_CODE %} |
|
4 | {% get_current_language as LANGUAGE_CODE %} | |
5 |
|
5 | |||
6 | <div class="{{ css_class }}" id="{{ post.id }}" data-uid="{{ post.uid }}"> |
|
6 | <div class="{{ css_class }}" id="{{ post.id }}" data-uid="{{ post.uid }}" {% if tree_depth %}style="margin-left: {{ tree_depth }}em;"{% endif %}> | |
7 | <div class="post-info"> |
|
7 | <div class="post-info"> | |
8 | <a class="post_id" href="{{ post.get_absolute_url }}">#{{ post.get_absolute_id }}</a> |
|
8 | <a class="post_id" href="{{ post.get_absolute_url }}">#{{ post.get_absolute_id }}</a> | |
9 | <span class="title">{{ post.title }}</span> |
|
9 | <span class="title">{{ post.title }}</span> | |
@@ -82,13 +82,7 b'' | |||||
82 | {% endautoescape %} |
|
82 | {% endautoescape %} | |
83 | </div> |
|
83 | </div> | |
84 | {% if post.is_referenced %} |
|
84 | {% if post.is_referenced %} | |
85 | {% if mode_tree %} |
|
85 | {% if not mode_tree %} | |
86 | <div class="tree_reply"> |
|
|||
87 | {% for refpost in post.get_referenced_posts %} |
|
|||
88 | {% post_view refpost mode_tree=True %} |
|
|||
89 | {% endfor %} |
|
|||
90 | </div> |
|
|||
91 | {% else %} |
|
|||
92 | <div class="refmap"> |
|
86 | <div class="refmap"> | |
93 | {% trans "Replies" %}: {{ post.refmap|safe }} |
|
87 | {% trans "Replies" %}: {{ post.refmap|safe }} | |
94 | </div> |
|
88 | </div> |
@@ -10,8 +10,8 b'' | |||||
10 | {% get_current_timezone as TIME_ZONE %} |
|
10 | {% get_current_timezone as TIME_ZONE %} | |
11 |
|
11 | |||
12 | <div class="thread"> |
|
12 | <div class="thread"> | |
13 |
{% for post in thread.get_ |
|
13 | {% for depth, post in thread.get_reply_tree %} | |
14 |
|
|
14 | {% post_view post mode_tree=True tree_depth=depth%} | |
15 | {% endfor %} |
|
15 | {% endfor %} | |
16 | </div> |
|
16 | </div> | |
17 |
|
17 |
General Comments 0
You need to be logged in to leave comments.
Login now