allura
Révision | e388ce210d390856fdd0a9604a9cb5d10dc0e74c (tree) |
---|---|
l'heure | 2011-11-17 04:48:17 |
Auteur | Jenny Steele <jsteele@geek...> |
Commiter | Wayne Witzel III |
[#3226] Added option to specify apps to install during register project so neighborhoods with a project template have more control
Signed-off-by: Jenny Steele <jsteele@geek.net>
@@ -170,11 +170,17 @@ class NeighborhoodController(object): | ||
170 | 170 | project_description = h.really_unicode(project_description or '').encode('utf-8') |
171 | 171 | project_name = h.really_unicode(project_name or '').encode('utf-8') |
172 | 172 | project_unixname = h.really_unicode(project_unixname or '').encode('utf-8').lower() |
173 | - c.project = neighborhood.register_project(project_unixname, project_name=project_name, private_project=private_project) | |
173 | + apps = None | |
174 | + if 'tools' in project_template: | |
175 | + apps = [] | |
176 | + c.project = neighborhood.register_project(project_unixname, project_name=project_name, private_project=private_project, apps=apps) | |
174 | 177 | if project_description: |
175 | 178 | c.project.short_description = project_description |
176 | 179 | ming.orm.ormsession.ThreadLocalORMSession.flush_all() |
177 | - offset = int(c.project.ordered_mounts(include_search=True)[-1]['ordinal']) + 1 | |
180 | + ordered_mounts = c.project.ordered_mounts(include_search=True) | |
181 | + offset = 0 | |
182 | + if len(ordered_mounts): | |
183 | + offset = int(ordered_mounts[-1]['ordinal']) + 1 | |
178 | 184 | if 'tools' in project_template: |
179 | 185 | for i, tool in enumerate(project_template['tools'].keys()): |
180 | 186 | tool_config = project_template['tools'][tool] |
@@ -198,16 +204,17 @@ class NeighborhoodController(object): | ||
198 | 204 | troves = getattr(c.project,'trove_%s'%trove_type) |
199 | 205 | for trove_id in project_template['trove_cats'][trove_type]: |
200 | 206 | troves.append(M.TroveCategory.query.get(trove_cat_id=trove_id)._id) |
201 | - if 'home_options' in project_template: | |
207 | + if 'home_options' in project_template and c.project.app_config('home'): | |
202 | 208 | options = c.project.app_config('home').options |
203 | 209 | for option in project_template['home_options'].keys(): |
204 | 210 | options[option] = project_template['home_options'][option] |
205 | - from forgewiki import model as WM | |
206 | 211 | home_app = c.project.app_instance('home') |
207 | - if 'home_text' in project_template: | |
208 | - WM.Page.query.get(app_config_id=home_app.config._id).text = project_template['home_text'] | |
209 | - else: | |
210 | - WM.Page.query.get(app_config_id=home_app.config._id).text = """[[project_admins]] | |
212 | + if home_app: | |
213 | + from forgewiki import model as WM | |
214 | + if 'home_text' in project_template: | |
215 | + WM.Page.query.get(app_config_id=home_app.config._id).text = project_template['home_text'] | |
216 | + else: | |
217 | + WM.Page.query.get(app_config_id=home_app.config._id).text = """[[project_admins]] | |
211 | 218 | [[download_button]]""" |
212 | 219 | if 'icon' in project_template: |
213 | 220 | icon_file = StringIO(urlopen(project_template['icon']['url']).read()) |
@@ -329,7 +329,7 @@ class ProjectRegistrationProvider(object): | ||
329 | 329 | state(p).soil() |
330 | 330 | return p |
331 | 331 | |
332 | - def register_project(self, neighborhood, shortname, project_name, user, user_project, private_project): | |
332 | + def register_project(self, neighborhood, shortname, project_name, user, user_project, private_project, apps=None): | |
333 | 333 | '''Register a new project in the neighborhood. The given user will |
334 | 334 | become the project's superuser. |
335 | 335 | ''' |
@@ -351,7 +351,8 @@ class ProjectRegistrationProvider(object): | ||
351 | 351 | p.configure_project( |
352 | 352 | users=[user], |
353 | 353 | is_user_project=user_project, |
354 | - is_private_project=private_project) | |
354 | + is_private_project=private_project, | |
355 | + apps=apps) | |
355 | 356 | except forge_exc.ProjectConflict: |
356 | 357 | raise |
357 | 358 | except: |
@@ -68,7 +68,7 @@ class Neighborhood(MappedClass): | ||
68 | 68 | else: |
69 | 69 | return url |
70 | 70 | |
71 | - def register_project(self, shortname, user=None, project_name=None, user_project=False, private_project=False): | |
71 | + def register_project(self, shortname, user=None, project_name=None, user_project=False, private_project=False, apps=None): | |
72 | 72 | '''Register a new project in the neighborhood. The given user will |
73 | 73 | become the project's superuser. If no user is specified, c.user is used. |
74 | 74 | ''' |
@@ -76,7 +76,7 @@ class Neighborhood(MappedClass): | ||
76 | 76 | if project_name is None: |
77 | 77 | project_name = shortname |
78 | 78 | return provider.register_project( |
79 | - self, shortname, project_name, user or getattr(c,'user',None), user_project, private_project) | |
79 | + self, shortname, project_name, user or getattr(c,'user',None), user_project, private_project, apps) | |
80 | 80 | |
81 | 81 | def bind_controller(self, controller): |
82 | 82 | from allura.controllers.project import NeighborhoodController |
@@ -202,11 +202,13 @@ class TestNeighborhood(TestController): | ||
202 | 202 | "filename":"icon.png" |
203 | 203 | }, |
204 | 204 | "tools":{ |
205 | + "wiki":{"label":"Home","mount_point":"home"}, | |
205 | 206 | "discussion":{"label":"Discussion","mount_point":"discussion"}, |
206 | 207 | "blog":{"label":"News","mount_point":"news","options":{ |
207 | 208 | "show_discussion":false |
208 | 209 | }}, |
209 | - "downloads":{"label":"Downloads","mount_point":"downloads"} | |
210 | + "downloads":{"label":"Downloads","mount_point":"downloads"}, | |
211 | + "admin":{"label":"Admin","mount_point":"admin"} | |
210 | 212 | }, |
211 | 213 | "tool_order":["home","discussion","news","downloads","admin"], |
212 | 214 | "labels":["mmi"], |