allura
Revisión | f0310aa3f51fd6f434f3fde3a584ff8c1412d146 (tree) |
---|---|
Tiempo | 2012-05-15 00:09:12 |
Autor | Cory Johns <johnsca@geek...> |
Commiter | Yaroslav Luzin |
[#4118] Some small bug fixes and touch-ups to profile desc -> wiki migration
Signed-off-by: Cory Johns <johnsca@geek.net>
@@ -1,4 +1,5 @@ | ||
1 | 1 | import logging |
2 | +import re | |
2 | 3 | |
3 | 4 | from pylons import c |
4 | 5 |
@@ -10,49 +11,45 @@ from forgewiki.wiki_main import ForgeWikiApp | ||
10 | 11 | |
11 | 12 | log = logging.getLogger(__name__) |
12 | 13 | |
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*$' | |
14 | 15 | |
15 | 16 | default_personal_project_tmpl = ("This is the personal project of %s." |
16 | 17 | " This project is created automatically during user registration" |
17 | 18 | " 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") | |
19 | 20 | |
20 | 21 | def main(): |
21 | 22 | for p in M.Project.query.find().all(): |
22 | - user = p.private_project_of() | |
23 | + user = p.user_project_of | |
23 | 24 | if not user: |
24 | 25 | continue |
25 | 26 | |
27 | + description = p.description | |
28 | + if description is None or re.match(default_description, description): | |
29 | + continue | |
30 | + | |
26 | 31 | app = p.app_instance('wiki') |
27 | 32 | if app is None: |
28 | 33 | p.install_app('wiki') |
29 | 34 | |
35 | + page = WM.Page.query.get(app_config_id=app.config._id, title='Home') | |
36 | + if page is None: | |
37 | + continue | |
38 | + | |
30 | 39 | c.app = app |
31 | 40 | c.project = p |
32 | 41 | c.user = user |
33 | 42 | |
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 | - | |
46 | 43 | if "This is the personal project of" in page.text: |
47 | 44 | 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) | |
49 | 47 | 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) | |
51 | 50 | else: |
52 | 51 | pass |
53 | 52 | |
54 | - log.info("Update wiki home page text for %s" % user.username) | |
55 | - | |
56 | 53 | ThreadLocalORMSession.flush_all() |
57 | 54 | |
58 | 55 | if __name__ == '__main__': |