]> git.openstreetmap.org Git - osqa.git/blobdiff - forum_modules/sximporter/importer.py
Reverting the merges due to unsuccessfull conflict resolvement.
[osqa.git] / forum_modules / sximporter / importer.py
index ec17de7e0461e916e06d929aaa259ac9cb63565d..0f7f812626e23968ff072493092218a5d984a383 100644 (file)
@@ -170,6 +170,7 @@ def userimport(path, options):
 #users = readTable(dump, "Users")
 
     usernames = []
 #users = readTable(dump, "Users")
 
     usernames = []
+    openids = set()
     uidmapper = IdMapper()
     #merged_users = []
 
     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)
         #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
             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)
         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()
             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)
 
 
     readTable(path, "Users", callback)
 
@@ -422,6 +432,7 @@ def postimport(dump, uidmap, tagmap):
         post.save()
 
         all.append(int(post.id))
         post.save()
 
         all.append(int(post.id))
+        create_and_activate_revision(post)
 
         del post
 
 
         del post
 
@@ -470,6 +481,8 @@ def comment_import(dump, uidmap, posts):
                 action_date = oc.added_at
                 )
 
                 action_date = oc.added_at
                 )
 
+        create_and_activate_revision(oc)
+
         create_action.save()
         oc.save()
 
         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
     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):
 
 
 def create_and_activate_revision(post):
@@ -763,6 +775,8 @@ def pages_import(dump, currid):
                 author_id = 1
                 )
 
                 author_id = 1
                 )
 
+        create_and_activate_revision(page)
+
         page.save()
         registry[sxp['url'][1:]] = page.id
 
         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
+