|
a/Allura/allura/controllers/project.py |
|
b/Allura/allura/controllers/project.py |
|
... |
|
... |
162 |
private_project=None, tools=None, **kw):
|
162 |
private_project=None, tools=None, **kw):
|
163 |
require_access(self.neighborhood, 'register')
|
163 |
require_access(self.neighborhood, 'register')
|
164 |
if private_project:
|
164 |
if private_project:
|
165 |
require_access(self.neighborhood, 'admin')
|
165 |
require_access(self.neighborhood, 'admin')
|
166 |
neighborhood = M.Neighborhood.query.get(name=neighborhood)
|
166 |
neighborhood = M.Neighborhood.query.get(name=neighborhood)
|
167 |
project_template = {}
|
|
|
168 |
if neighborhood.project_template:
|
|
|
169 |
project_template = json.loads(neighborhood.project_template)
|
|
|
170 |
if 'private' in project_template:
|
|
|
171 |
private_project = project_template['private']
|
|
|
172 |
project_description = h.really_unicode(project_description or '').encode('utf-8')
|
167 |
project_description = h.really_unicode(project_description or '').encode('utf-8')
|
173 |
project_name = h.really_unicode(project_name or '').encode('utf-8')
|
168 |
project_name = h.really_unicode(project_name or '').encode('utf-8')
|
174 |
project_unixname = h.really_unicode(project_unixname or '').encode('utf-8').lower()
|
169 |
project_unixname = h.really_unicode(project_unixname or '').encode('utf-8').lower()
|
175 |
apps = None
|
170 |
c.project = neighborhood.register_project(project_unixname,
|
176 |
if 'tools' in project_template:
|
171 |
project_name=project_name, private_project=private_project)
|
177 |
apps = []
|
|
|
178 |
c.project = neighborhood.register_project(project_unixname, project_name=project_name, private_project=private_project, apps=apps)
|
|
|
179 |
if project_description:
|
172 |
if project_description:
|
180 |
c.project.short_description = project_description
|
173 |
c.project.short_description = project_description
|
181 |
ming.orm.ormsession.ThreadLocalORMSession.flush_all()
|
|
|
182 |
ordered_mounts = c.project.ordered_mounts(include_search=True)
|
174 |
offset = c.project.next_mount_point(include_search=True)
|
183 |
offset = 0
|
175 |
if tools and not neighborhood.project_template:
|
184 |
if len(ordered_mounts):
|
|
|
185 |
offset = int(ordered_mounts[-1]['ordinal']) + 1
|
|
|
186 |
if 'tools' in project_template:
|
|
|
187 |
for i, tool in enumerate(project_template['tools'].keys()):
|
|
|
188 |
tool_config = project_template['tools'][tool]
|
|
|
189 |
app = c.project.install_app(tool,
|
|
|
190 |
mount_label=tool_config['label'],
|
|
|
191 |
mount_point=tool_config['mount_point'],
|
|
|
192 |
ordinal=i+offset)
|
|
|
193 |
if 'options' in tool_config:
|
|
|
194 |
for option in tool_config['options']:
|
|
|
195 |
app.config.options[option] = tool_config['options'][option]
|
|
|
196 |
elif tools:
|
|
|
197 |
for i, tool in enumerate(tools):
|
176 |
for i, tool in enumerate(tools):
|
198 |
c.project.install_app(tool, ordinal=i+offset)
|
177 |
c.project.install_app(tool, ordinal=i+offset)
|
199 |
if 'tool_order' in project_template:
|
|
|
200 |
for i, tool in enumerate(project_template['tool_order']):
|
|
|
201 |
c.project.app_config(tool).options.ordinal = i
|
|
|
202 |
if 'labels' in project_template:
|
|
|
203 |
c.project.labels = project_template['labels']
|
|
|
204 |
if 'trove_cats' in project_template:
|
|
|
205 |
for trove_type in project_template['trove_cats'].keys():
|
|
|
206 |
troves = getattr(c.project,'trove_%s'%trove_type)
|
|
|
207 |
for trove_id in project_template['trove_cats'][trove_type]:
|
|
|
208 |
troves.append(M.TroveCategory.query.get(trove_cat_id=trove_id)._id)
|
|
|
209 |
if 'home_options' in project_template and c.project.app_config('home'):
|
|
|
210 |
options = c.project.app_config('home').options
|
|
|
211 |
for option in project_template['home_options'].keys():
|
|
|
212 |
options[option] = project_template['home_options'][option]
|
|
|
213 |
home_app = c.project.app_instance('home')
|
|
|
214 |
if home_app:
|
|
|
215 |
from forgewiki import model as WM
|
|
|
216 |
if 'home_text' in project_template:
|
|
|
217 |
WM.Page.query.get(app_config_id=home_app.config._id).text = project_template['home_text']
|
|
|
218 |
else:
|
|
|
219 |
WM.Page.query.get(app_config_id=home_app.config._id).text = """[[project_admins]]
|
|
|
220 |
[[download_button]]"""
|
|
|
221 |
if 'icon' in project_template:
|
|
|
222 |
icon_file = StringIO(urlopen(project_template['icon']['url']).read())
|
|
|
223 |
M.ProjectFile.save_image(
|
|
|
224 |
project_template['icon']['filename'], icon_file,
|
|
|
225 |
square=True, thumbnail_size=(48,48),
|
|
|
226 |
thumbnail_meta=dict(project_id=c.project._id,category='icon'))
|
|
|
227 |
flash('Welcome to the SourceForge Beta System! '
|
178 |
flash('Welcome to the SourceForge Beta System! '
|
228 |
'To get started, fill out some information about your project.')
|
179 |
'To get started, fill out some information about your project.')
|
229 |
redirect(c.project.script_name + 'admin/overview')
|
180 |
redirect(c.project.script_name + 'admin/overview')
|
230 |
|
181 |
|
231 |
@expose()
|
182 |
@expose()
|