X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/af86787210acddeca6800db8e6e7106edd3973cc..13bee2f2e6aea2d936909861f3ab60bb09821a60:/forum_modules/sximporter/importer.py?ds=sidebyside diff --git a/forum_modules/sximporter/importer.py b/forum_modules/sximporter/importer.py index ec17de7..0f7f812 100644 --- a/forum_modules/sximporter/importer.py +++ b/forum_modules/sximporter/importer.py @@ -170,6 +170,7 @@ def userimport(path, options): #users = readTable(dump, "Users") usernames = [] + openids = set() uidmapper = IdMapper() #merged_users = [] @@ -186,6 +187,8 @@ def userimport(path, options): #print "\n".join(["%s : %s" % i for i in sxu.items()]) if int(sxu.get('id')) == int(owneruid): osqau = orm.User.objects.get(id=1) + for assoc in orm.AuthKeyUserAssociation.objects.filter(user=osqau): + openids.add(assoc.key) uidmapper[owneruid] = 1 uidmapper[-1] = 1 create = False @@ -290,9 +293,16 @@ def userimport(path, options): usernames.append(osqau.username) openid = sxu.get('openid', None) - if openid and openidre.match(openid): + if openid and openidre.match(openid) and (not openid in openids): assoc = orm.AuthKeyUserAssociation(user=osqau, key=openid, provider="openidurl") assoc.save() + openids.add(openid) + + openidalt = sxu.get('openidalt', None) + if openidalt and openidre.match(openidalt) and (not openidalt in openids): + assoc = orm.AuthKeyUserAssociation(user=osqau, key=openidalt, provider="openidurl") + assoc.save() + openids.add(openidalt) readTable(path, "Users", callback) @@ -422,6 +432,7 @@ def postimport(dump, uidmap, tagmap): post.save() all.append(int(post.id)) + create_and_activate_revision(post) del post @@ -470,6 +481,8 @@ def comment_import(dump, uidmap, posts): action_date = oc.added_at ) + create_and_activate_revision(oc) + create_action.save() oc.save() @@ -484,7 +497,6 @@ def add_tags_to_post(post, tagmap): tags = [tag for tag in [tagmap.get(name.strip()) for name in post.tagnames.split(u' ') if name] if tag] post.tagnames = " ".join([t.name for t in tags]).strip() post.tags = tags - create_and_activate_revision(post) def create_and_activate_revision(post): @@ -763,6 +775,8 @@ def pages_import(dump, currid): author_id = 1 ) + create_and_activate_revision(page) + page.save() registry[sxp['url'][1:]] = page.id @@ -989,4 +1003,4 @@ SELECT setval('"forum_openidassociation_id_seq"', coalesce(max("id"), 1) + 2, ma - \ No newline at end of file +