|
a/Allura/allura/lib/plugin.py |
|
b/Allura/allura/lib/plugin.py |
|
... |
|
... |
334 |
def register_project(self, neighborhood, shortname, project_name, user, user_project, private_project, apps=None):
|
334 |
def register_project(self, neighborhood, shortname, project_name, user, user_project, private_project, apps=None):
|
335 |
'''Register a new project in the neighborhood. The given user will
|
335 |
'''Register a new project in the neighborhood. The given user will
|
336 |
become the project's superuser.
|
336 |
become the project's superuser.
|
337 |
'''
|
337 |
'''
|
338 |
from allura import model as M
|
338 |
from allura import model as M
|
|
|
339 |
|
|
|
340 |
# Check for private project rights
|
|
|
341 |
if neighborhood.allow_private == False and private_project:
|
|
|
342 |
raise ValueError("You can't create private projects for %s neighborhood" % neighborhood.name)
|
|
|
343 |
|
|
|
344 |
# Check for project limit creation
|
|
|
345 |
pq = M.Project.query.find(dict(
|
|
|
346 |
neighborhood_id=neighborhood._id,
|
|
|
347 |
deleted=False,
|
|
|
348 |
shortname={'$ne':'--init--'}
|
|
|
349 |
))
|
|
|
350 |
count = pq.count()
|
|
|
351 |
nb_max_projects = neighborhood.get_max_projects()
|
|
|
352 |
|
|
|
353 |
if nb_max_projects is not None and count >= nb_max_projects:
|
|
|
354 |
log.exception('Error registering project %s' % project_name)
|
|
|
355 |
raise forge_exc.ProjectOverlimitError()
|
|
|
356 |
|
339 |
if not h.re_path_portion.match(shortname.replace('/', '')):
|
357 |
if not h.re_path_portion.match(shortname.replace('/', '')):
|
340 |
raise ValueError('Invalid project shortname: %s' % shortname)
|
358 |
raise ValueError('Invalid project shortname: %s' % shortname)
|
341 |
try:
|
359 |
try:
|
342 |
p = M.Project.query.get(shortname=shortname, neighborhood_id=neighborhood._id)
|
360 |
p = M.Project.query.get(shortname=shortname, neighborhood_id=neighborhood._id)
|
343 |
if p:
|
361 |
if p:
|