--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -164,66 +164,17 @@
if private_project:
require_access(self.neighborhood, 'admin')
neighborhood = M.Neighborhood.query.get(name=neighborhood)
- project_template = {}
- if neighborhood.project_template:
- project_template = json.loads(neighborhood.project_template)
- if 'private' in project_template:
- private_project = project_template['private']
project_description = h.really_unicode(project_description or '').encode('utf-8')
project_name = h.really_unicode(project_name or '').encode('utf-8')
project_unixname = h.really_unicode(project_unixname or '').encode('utf-8').lower()
- apps = None
- if 'tools' in project_template:
- apps = []
- c.project = neighborhood.register_project(project_unixname, project_name=project_name, private_project=private_project, apps=apps)
+ c.project = neighborhood.register_project(project_unixname,
+ project_name=project_name, private_project=private_project)
if project_description:
c.project.short_description = project_description
- ming.orm.ormsession.ThreadLocalORMSession.flush_all()
- ordered_mounts = c.project.ordered_mounts(include_search=True)
- offset = 0
- if len(ordered_mounts):
- offset = int(ordered_mounts[-1]['ordinal']) + 1
- if 'tools' in project_template:
- for i, tool in enumerate(project_template['tools'].keys()):
- tool_config = project_template['tools'][tool]
- app = c.project.install_app(tool,
- mount_label=tool_config['label'],
- mount_point=tool_config['mount_point'],
- ordinal=i+offset)
- if 'options' in tool_config:
- for option in tool_config['options']:
- app.config.options[option] = tool_config['options'][option]
- elif tools:
+ offset = c.project.next_mount_point(include_search=True)
+ if tools and not neighborhood.project_template:
for i, tool in enumerate(tools):
c.project.install_app(tool, ordinal=i+offset)
- if 'tool_order' in project_template:
- for i, tool in enumerate(project_template['tool_order']):
- c.project.app_config(tool).options.ordinal = i
- if 'labels' in project_template:
- c.project.labels = project_template['labels']
- if 'trove_cats' in project_template:
- for trove_type in project_template['trove_cats'].keys():
- troves = getattr(c.project,'trove_%s'%trove_type)
- for trove_id in project_template['trove_cats'][trove_type]:
- troves.append(M.TroveCategory.query.get(trove_cat_id=trove_id)._id)
- if 'home_options' in project_template and c.project.app_config('home'):
- options = c.project.app_config('home').options
- for option in project_template['home_options'].keys():
- options[option] = project_template['home_options'][option]
- home_app = c.project.app_instance('home')
- if home_app:
- from forgewiki import model as WM
- if 'home_text' in project_template:
- WM.Page.query.get(app_config_id=home_app.config._id).text = project_template['home_text']
- else:
- WM.Page.query.get(app_config_id=home_app.config._id).text = """[[project_admins]]
-[[download_button]]"""
- if 'icon' in project_template:
- icon_file = StringIO(urlopen(project_template['icon']['url']).read())
- M.ProjectFile.save_image(
- project_template['icon']['filename'], icon_file,
- square=True, thumbnail_size=(48,48),
- thumbnail_meta=dict(project_id=c.project._id,category='icon'))
flash('Welcome to the SourceForge Beta System! '
'To get started, fill out some information about your project.')
redirect(c.project.script_name + 'admin/overview')