]> git.openstreetmap.org Git - osqa.git/commitdiff
the importer was not loading accepted answers correctly
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 22 Apr 2010 23:57:05 +0000 (23:57 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 22 Apr 2010 23:57:05 +0000 (23:57 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@65 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum_modules/sximporter/importer.py

index 1ab6abe9951fdec43458b2d8677e44e2a71ff22e..2ae3c748efbdde9267035ae3bf986baddbd8ae6f 100644 (file)
@@ -173,6 +173,7 @@ def tagsimport(dump, uidmap):
 \r
 def postimport(dump, uidmap, tagmap):\r
     history = {}\r
+    accepted = {}\r
     all = {}\r
 \r
     for h in readTable(dump, "PostHistory"):\r
@@ -184,8 +185,6 @@ def postimport(dump, uidmap, tagmap):
     posts = readTable(dump, "Posts")\r
 \r
     for sxpost in posts:\r
-        accepted = {}\r
-\r
         postclass = sxpost.get('posttypeid') == '1' and orm.Question or orm.Answer\r
 \r
         post = postclass(\r
@@ -233,6 +232,7 @@ def postimport(dump, uidmap, tagmap):
                 post.closed_at = datetime.now()\r
 \r
             if sxpost.get('acceptedanswerid', None):\r
+                post.accepted_answer_id = int(sxpost.get('acceptedanswerid'))\r
                 accepted[int(sxpost.get('acceptedanswerid'))] = post\r
 \r
         else:\r
@@ -240,13 +240,9 @@ def postimport(dump, uidmap, tagmap):
             post.parent_id = sxpost['parentid']\r
 \r
             if int(post.id) in accepted:\r
-                question = accepted[int(post.id)]\r
-                question.accepted_answer_id = post\r
-                question.save()\r
-\r
                 post.accepted = True\r
                 post.accepted_at = datetime.now()\r
-                post.accepted_by_id = question.author_id\r
+                post.accepted_by_id = accepted[int(post.id)].author_id\r
 \r
         all[int(post.id)] = post\r
 \r
@@ -426,6 +422,7 @@ def sximport(dump, options):
     \r
     \r
 PG_SEQUENCE_RESETS = """\r
+SELECT setval('"auth_user_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user";\r
 SELECT setval('"auth_user_groups_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user_groups";\r
 SELECT setval('"auth_user_user_permissions_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user_user_permissions";\r
 SELECT setval('"activity_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "activity";\r