##// END OF EJS Templates
Fixed tree child positions
neko259 -
r1487:e4a035cf default
parent child Browse files
Show More
@@ -282,6 +282,7 b' class Thread(models.Model):'
282 282 def get_reply_tree(self):
283 283 replies = self.get_replies().prefetch_related('refposts')
284 284 tree = []
285 parent_positions = {}
285 286 for reply in replies:
286 287 parents = reply.refposts.all()
287 288 found_parent = False
@@ -290,8 +291,11 b' class Thread(models.Model):'
290 291 for depth, element in tree:
291 292 index += 1
292 293 if element in parents:
293 tree.insert(index, (depth + 1, reply))
294 offset_under_parent = parent_positions.get(element, 1)
295 tree.insert(index + offset_under_parent - 1, (depth + 1, reply))
296 parent_positions[element] = offset_under_parent + 1
294 297 found_parent = True
298
295 299 if not found_parent:
296 300 tree.append((0, reply))
297 301
General Comments 0
You need to be logged in to leave comments. Login now