[#4118] Some small bug fixes and touch-ups to profile desc -> wiki migration

Signed-off-by: Cory Johns <johnsca@geek.net>
diff --git a/scripts/migrations/023-migrate-custom-profile-text.py b/scripts/migrations/023-migrate-custom-profile-text.py
index 6ee0617..e2eda7d 100644
--- a/scripts/migrations/023-migrate-custom-profile-text.py
+++ b/scripts/migrations/023-migrate-custom-profile-text.py
@@ -1,4 +1,5 @@
 import logging
+import re
 
 from pylons import c
 
@@ -10,49 +11,45 @@
 
 log = logging.getLogger(__name__)
 
-default_description = u'You can edit this description in the admin page'
+default_description = r'^\s*(?:You can edit this description in the admin page)?\s*$'
 
 default_personal_project_tmpl = ("This is the personal project of %s."
             " This project is created automatically during user registration"
             " as an easy place to store personal data that doesn't need its own"
-            " project such as cloned repositories.\n%s")
+            " project such as cloned repositories.\n\n%s")
 
 def main():
     for p in M.Project.query.find().all():
-        user = p.private_project_of()
+        user = p.user_project_of
         if not user:
             continue
 
+        description = p.description
+        if description is None or re.match(default_description, description):
+            continue
+
         app = p.app_instance('wiki')
         if app is None:
             p.install_app('wiki')
 
+        page = WM.Page.query.get(app_config_id=app.config._id, title='Home')
+        if page is None:
+            continue
+
         c.app = app
         c.project = p
         c.user = user
 
-        page = WM.Page.query.get(app_config_id=c.app.config._id, title='Home')
-        if page is None:
-            c.app.install(p)
-            page = WM.Page.query.get(app_config_id=c.app.config._id, title='Home')
-            if page is None:
-                log.info("Can't add page for %s home project" % user.username)
-                continue
-
-        description = p.description
-        if description is None or description == "":
-            description = default_description
-
         if "This is the personal project of" in page.text:
             if description not in page.text:
-                page.text = "%s\n%s" % (page.text, description)
+                page.text = "%s\n\n%s" % (page.text, description)
+                log.info("Update wiki home page text for %s" % user.username)
         elif "This is the default page" in page.text:
-            page.text = default_personal_project_tmpl % (user.username, description)
+            page.text = default_personal_project_tmpl % (user.display_name, description)
+            log.info("Update wiki home page text for %s" % user.username)
         else:
             pass
 
-        log.info("Update wiki home page text for %s" % user.username)
-
     ThreadLocalORMSession.flush_all()
 
 if __name__ == '__main__':