• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

Revisiónf0310aa3f51fd6f434f3fde3a584ff8c1412d146 (tree)
Tiempo2012-05-15 00:09:12
AutorCory Johns <johnsca@geek...>
CommiterYaroslav Luzin

Log Message

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

Signed-off-by: Cory Johns <johnsca@geek.net>

Cambiar Resumen

Diferencia incremental

--- a/scripts/migrations/023-migrate-custom-profile-text.py
+++ b/scripts/migrations/023-migrate-custom-profile-text.py
@@ -1,4 +1,5 @@
11 import logging
2+import re
23
34 from pylons import c
45
@@ -10,49 +11,45 @@ from forgewiki.wiki_main import ForgeWikiApp
1011
1112 log = logging.getLogger(__name__)
1213
13-default_description = u'You can edit this description in the admin page'
14+default_description = r'^\s*(?:You can edit this description in the admin page)?\s*$'
1415
1516 default_personal_project_tmpl = ("This is the personal project of %s."
1617 " This project is created automatically during user registration"
1718 " as an easy place to store personal data that doesn't need its own"
18- " project such as cloned repositories.\n%s")
19+ " project such as cloned repositories.\n\n%s")
1920
2021 def main():
2122 for p in M.Project.query.find().all():
22- user = p.private_project_of()
23+ user = p.user_project_of
2324 if not user:
2425 continue
2526
27+ description = p.description
28+ if description is None or re.match(default_description, description):
29+ continue
30+
2631 app = p.app_instance('wiki')
2732 if app is None:
2833 p.install_app('wiki')
2934
35+ page = WM.Page.query.get(app_config_id=app.config._id, title='Home')
36+ if page is None:
37+ continue
38+
3039 c.app = app
3140 c.project = p
3241 c.user = user
3342
34- page = WM.Page.query.get(app_config_id=c.app.config._id, title='Home')
35- if page is None:
36- c.app.install(p)
37- page = WM.Page.query.get(app_config_id=c.app.config._id, title='Home')
38- if page is None:
39- log.info("Can't add page for %s home project" % user.username)
40- continue
41-
42- description = p.description
43- if description is None or description == "":
44- description = default_description
45-
4643 if "This is the personal project of" in page.text:
4744 if description not in page.text:
48- page.text = "%s\n%s" % (page.text, description)
45+ page.text = "%s\n\n%s" % (page.text, description)
46+ log.info("Update wiki home page text for %s" % user.username)
4947 elif "This is the default page" in page.text:
50- page.text = default_personal_project_tmpl % (user.username, description)
48+ page.text = default_personal_project_tmpl % (user.display_name, description)
49+ log.info("Update wiki home page text for %s" % user.username)
5150 else:
5251 pass
5352
54- log.info("Update wiki home page text for %s" % user.username)
55-
5653 ThreadLocalORMSession.flush_all()
5754
5855 if __name__ == '__main__':