src/cm/views/create.py
changeset 499 805e08ea57b1
parent 463 9c7de6dd1723
child 613 a0b695aace0a
--- a/src/cm/views/create.py	Thu Jan 31 14:54:54 2013 +0100
+++ b/src/cm/views/create.py	Thu Jan 31 16:56:09 2013 +0100
@@ -195,7 +195,9 @@
       # Process comments.
       if soup.co_ment_text.comments:
         comments_ids_map = {}
-        for imported_comment in soup.co_ment_text.comments.findAll('comment'):
+        all_comments = soup.co_ment_text.comments.findAll('comment')
+        # Sort by id in order to have parent processed before reply_to
+        for imported_comment in sorted(all_comments, key=lambda cid: cid.id.renderContents()):
           # Creates each comment.
           comment = Comment.objects.create(
               text_version=text.get_latest_version(),