From 4c33db476687ae1d3e0e518fb79652184b8322ec Mon Sep 17 00:00:00 2001 From: hernani Date: Thu, 22 Apr 2010 23:57:05 +0000 Subject: [PATCH] the importer was not loading accepted answers correctly git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@65 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum_modules/sximporter/importer.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/forum_modules/sximporter/importer.py b/forum_modules/sximporter/importer.py index 1ab6abe..2ae3c74 100644 --- a/forum_modules/sximporter/importer.py +++ b/forum_modules/sximporter/importer.py @@ -173,6 +173,7 @@ def tagsimport(dump, uidmap): def postimport(dump, uidmap, tagmap): history = {} + accepted = {} all = {} for h in readTable(dump, "PostHistory"): @@ -184,8 +185,6 @@ def postimport(dump, uidmap, tagmap): posts = readTable(dump, "Posts") for sxpost in posts: - accepted = {} - postclass = sxpost.get('posttypeid') == '1' and orm.Question or orm.Answer post = postclass( @@ -233,6 +232,7 @@ def postimport(dump, uidmap, tagmap): post.closed_at = datetime.now() if sxpost.get('acceptedanswerid', None): + post.accepted_answer_id = int(sxpost.get('acceptedanswerid')) accepted[int(sxpost.get('acceptedanswerid'))] = post else: @@ -240,13 +240,9 @@ def postimport(dump, uidmap, tagmap): post.parent_id = sxpost['parentid'] if int(post.id) in accepted: - question = accepted[int(post.id)] - question.accepted_answer_id = post - question.save() - post.accepted = True post.accepted_at = datetime.now() - post.accepted_by_id = question.author_id + post.accepted_by_id = accepted[int(post.id)].author_id all[int(post.id)] = post @@ -426,6 +422,7 @@ def sximport(dump, options): PG_SEQUENCE_RESETS = """ +SELECT setval('"auth_user_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user"; SELECT setval('"auth_user_groups_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user_groups"; SELECT setval('"auth_user_user_permissions_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "auth_user_user_permissions"; SELECT setval('"activity_id_seq"', coalesce(max("id"), 1) + 2, max("id") IS NOT null) FROM "activity"; -- 2.39.5