\r
def postimport(dump, uidmap, tagmap):\r
history = {}\r
+ accepted = {}\r
all = {}\r
\r
for h in readTable(dump, "PostHistory"):\r
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
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
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
\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