|
... |
|
... |
306 |
try:
|
306 |
try:
|
307 |
p.configure_project(
|
307 |
p.configure_project(
|
308 |
users=users,
|
308 |
users=users,
|
309 |
is_user_project=False,
|
309 |
is_user_project=False,
|
310 |
apps=[
|
310 |
apps=[
|
311 |
('wiki', 'home'),
|
311 |
('Wiki', 'home', 'Home'),
|
312 |
('admin', 'admin')])
|
312 |
('admin', 'admin', 'Admin')])
|
313 |
except:
|
313 |
except:
|
314 |
ThreadLocalORMSession.close_all()
|
314 |
ThreadLocalORMSession.close_all()
|
315 |
log.exception('Error registering project %s' % p)
|
315 |
log.exception('Error registering project %s' % p)
|
316 |
raise
|
316 |
raise
|
317 |
if allow_register:
|
317 |
if allow_register:
|
|
... |
|
... |
323 |
def register_project(self, neighborhood, shortname, user, user_project, private_project):
|
323 |
def register_project(self, neighborhood, shortname, user, user_project, private_project):
|
324 |
'''Register a new project in the neighborhood. The given user will
|
324 |
'''Register a new project in the neighborhood. The given user will
|
325 |
become the project's superuser. If no user is specified, c.user is used.
|
325 |
become the project's superuser. If no user is specified, c.user is used.
|
326 |
'''
|
326 |
'''
|
327 |
from allura import model as M
|
327 |
from allura import model as M
|
328 |
assert h.re_path_portion.match(shortname.replace('/', '')), \
|
328 |
if not h.re_path_portion.match(shortname.replace('/', '')):
|
329 |
'Invalid project shortname'
|
329 |
raise ValueError('Invalid project shortname: %s' % shortname)
|
330 |
try:
|
330 |
try:
|
331 |
p = M.Project.query.get(shortname=shortname)
|
331 |
p = M.Project.query.get(shortname=shortname)
|
332 |
if p: raise forge_exc.ProjectConflict()
|
332 |
if p: raise forge_exc.ProjectConflict()
|
333 |
p = M.Project(neighborhood_id=neighborhood._id,
|
333 |
p = M.Project(neighborhood_id=neighborhood._id,
|
334 |
shortname=shortname,
|
334 |
shortname=shortname,
|
|
... |
|
... |
369 |
last_updated = datetime.utcnow(),
|
369 |
last_updated = datetime.utcnow(),
|
370 |
is_root=False)
|
370 |
is_root=False)
|
371 |
with h.push_config(c, project=sp):
|
371 |
with h.push_config(c, project=sp):
|
372 |
M.AppConfig.query.remove(dict(project_id=c.project._id))
|
372 |
M.AppConfig.query.remove(dict(project_id=c.project._id))
|
373 |
if install_apps:
|
373 |
if install_apps:
|
374 |
sp.install_app('home', 'home')
|
374 |
home_app = sp.install_app('Wiki', 'home', 'Home', ordinal=0)
|
|
|
375 |
if home_app:
|
|
|
376 |
home_app.show_discussion = False
|
|
|
377 |
home_app.show_left_bar = False
|
375 |
sp.install_app('admin', 'admin')
|
378 |
sp.install_app('admin', 'admin', ordinal=1)
|
376 |
sp.install_app('search', 'search')
|
379 |
sp.install_app('search', 'search', ordinal=2)
|
377 |
g.post_event('project_created')
|
380 |
g.post_event('project_created')
|
378 |
return sp
|
381 |
return sp
|
379 |
|
382 |
|
380 |
def delete_project(self, project, user):
|
383 |
def delete_project(self, project, user):
|
381 |
for sp in project.subprojects:
|
384 |
for sp in project.subprojects:
|