|
a/scripts/migrations/012-uninstall-home.py |
|
b/scripts/migrations/012-uninstall-home.py |
|
... |
|
... |
47 |
if test:
|
47 |
if test:
|
48 |
log.info('would create Wiki "home" for project ' + project.shortname)
|
48 |
log.info('would create Wiki "home" for project ' + project.shortname)
|
49 |
else:
|
49 |
else:
|
50 |
log.info('creating Wiki "home" for project ' + project.shortname)
|
50 |
log.info('creating Wiki "home" for project ' + project.shortname)
|
51 |
home_title = project.homepage_title or 'Home'
|
51 |
home_title = project.homepage_title or 'Home'
|
52 |
home_text = project.description or ''
|
52 |
wiki_text = project.description or ''
|
53 |
if home_text == 'You can edit this description in the admin page':
|
53 |
if wiki_text == 'You can edit this description in the admin page':
|
54 |
home_text = 'You can edit this description'
|
54 |
wiki_text = 'You can edit this description'
|
55 |
|
55 |
|
56 |
# re-number all the mounts so the new Wiki comes first
|
56 |
# re-number all the mounts so the new Wiki comes first
|
57 |
mounts = project.ordered_mounts()
|
57 |
mounts = project.ordered_mounts()
|
58 |
with patch('forgewiki.model.wiki.Notification.post', notification_post):
|
58 |
with patch('forgewiki.model.wiki.Notification.post', notification_post):
|
59 |
new_home_app = project.install_app('Wiki', 'home', 'Home')
|
59 |
new_home_app = project.install_app('Wiki', 'home', 'Home')
|
|
... |
|
... |
78 |
# weird: we didn't find the existing home page
|
78 |
# weird: we didn't find the existing home page
|
79 |
log.warning('hmmm, actually creating the home page ("%s") for project "%s" from scratch' % (home_title, project.shortname))
|
79 |
log.warning('hmmm, actually creating the home page ("%s") for project "%s" from scratch' % (home_title, project.shortname))
|
80 |
new_home_page = WM.Page.upsert(home_title)
|
80 |
new_home_page = WM.Page.upsert(home_title)
|
81 |
new_home_page.viewable_by = ['all']
|
81 |
new_home_page.viewable_by = ['all']
|
82 |
new_home_page.title = home_title
|
82 |
new_home_page.title = home_title
|
83 |
new_home_page.text = home_text
|
83 |
new_home_page.text = wiki_text
|
84 |
with patch('forgewiki.model.wiki.Notification.post', notification_post):
|
84 |
with patch('forgewiki.model.wiki.Notification.post', notification_post):
|
85 |
new_home_page.commit()
|
85 |
new_home_page.commit()
|
86 |
assert new_home_page is not None
|
86 |
assert new_home_page is not None
|
87 |
assert new_home_page.title == home_title
|
87 |
assert new_home_page.title == home_title
|
88 |
assert new_home_page.version == 2
|
88 |
assert new_home_page.version == 2
|