|
a/Allura/allura/lib/plugin.py |
|
b/Allura/allura/lib/plugin.py |
|
... |
|
... |
246 |
|
246 |
|
247 |
def register_project(self, neighborhood, shortname, user, user_project):
|
247 |
def register_project(self, neighborhood, shortname, user, user_project):
|
248 |
'''Register a new project in the neighborhood. The given user will
|
248 |
'''Register a new project in the neighborhood. The given user will
|
249 |
become the project's superuser. If no user is specified, c.user is used.
|
249 |
become the project's superuser. If no user is specified, c.user is used.
|
250 |
'''
|
250 |
'''
|
|
|
251 |
import allura.tasks.event_tasks
|
251 |
from allura import model as M
|
252 |
from allura import model as M
|
252 |
assert h.re_path_portion.match(shortname.replace('/', '')), \
|
253 |
assert h.re_path_portion.match(shortname.replace('/', '')), \
|
253 |
'Invalid project shortname'
|
254 |
'Invalid project shortname'
|
254 |
try:
|
255 |
try:
|
255 |
p = M.Project.query.get(shortname=shortname)
|
256 |
p = M.Project.query.get(shortname=shortname)
|
|
... |
|
... |
272 |
ThreadLocalORMSession.close_all()
|
273 |
ThreadLocalORMSession.close_all()
|
273 |
log.exception('Error registering project %s' % p)
|
274 |
log.exception('Error registering project %s' % p)
|
274 |
raise
|
275 |
raise
|
275 |
ThreadLocalORMSession.flush_all()
|
276 |
ThreadLocalORMSession.flush_all()
|
276 |
with h.push_config(c, project=p, user=user):
|
277 |
with h.push_config(c, project=p, user=user):
|
277 |
# have to add user to context, since this may occur inside auth code for user-project reg, and c.user isn't set yet
|
278 |
# have to add user to context, since this may occur inside auth code
|
278 |
g.publish('react', 'forge.project_created')
|
279 |
# for user-project reg, and c.user isn't set yet
|
|
|
280 |
allura.tasks.event_tasks.event.post('project_created')
|
279 |
return p
|
281 |
return p
|
280 |
|
282 |
|
281 |
def register_subproject(self, project, name, user, install_apps):
|
283 |
def register_subproject(self, project, name, user, install_apps):
|
282 |
from allura import model as M
|
284 |
from allura import model as M
|
|
|
285 |
import allura.tasks.event_tasks
|
283 |
assert h.re_path_portion.match(name), 'Invalid subproject shortname'
|
286 |
assert h.re_path_portion.match(name), 'Invalid subproject shortname'
|
284 |
shortname = project.shortname + '/' + name
|
287 |
shortname = project.shortname + '/' + name
|
285 |
sp = M.Project(
|
288 |
sp = M.Project(
|
286 |
parent_id=project._id,
|
289 |
parent_id=project._id,
|
287 |
neighborhood_id=project.neighborhood_id,
|
290 |
neighborhood_id=project.neighborhood_id,
|
|
... |
|
... |
294 |
M.AppConfig.query.remove(dict(project_id=c.project._id))
|
297 |
M.AppConfig.query.remove(dict(project_id=c.project._id))
|
295 |
if install_apps:
|
298 |
if install_apps:
|
296 |
sp.install_app('home', 'home')
|
299 |
sp.install_app('home', 'home')
|
297 |
sp.install_app('admin', 'admin')
|
300 |
sp.install_app('admin', 'admin')
|
298 |
sp.install_app('search', 'search')
|
301 |
sp.install_app('search', 'search')
|
299 |
g.publish('react', 'forge.project_created')
|
302 |
allura.tasks.event_tasks.event.post('project_created')
|
300 |
return sp
|
303 |
return sp
|
301 |
|
304 |
|
302 |
def delete_project(self, project, user):
|
305 |
def delete_project(self, project, user):
|
303 |
for sp in project.subprojects:
|
306 |
for sp in project.subprojects:
|
304 |
self.delete_project(sp, user)
|
307 |
self.delete_project(sp, user)
|