Switch to unified view

a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
...
...
24
from allura.lib.security import require_access, has_access
24
from allura.lib.security import require_access, has_access
25
from allura.lib.security import RoleCache
25
from allura.lib.security import RoleCache
26
from allura.lib.widgets import forms as ff
26
from allura.lib.widgets import forms as ff
27
from allura.lib.widgets import form_fields as ffw
27
from allura.lib.widgets import form_fields as ffw
28
from allura.lib.widgets import project_list as plw
28
from allura.lib.widgets import project_list as plw
29
from allura.lib import plugin
29
from allura.lib import plugin, exceptions
30
from .auth import AuthController
30
from .auth import AuthController
31
from .search import SearchController, ProjectBrowseController
31
from .search import SearchController, ProjectBrowseController
32
from .static import NewForgeController
32
from .static import NewForgeController
33
33
34
log = logging.getLogger(__name__)
34
log = logging.getLogger(__name__)
...
...
100
        if sort=='alpha':
100
        if sort=='alpha':
101
            pq.sort('name')
101
            pq.sort('name')
102
        else:
102
        else:
103
            pq.sort('last_updated', pymongo.DESCENDING)
103
            pq.sort('last_updated', pymongo.DESCENDING)
104
        count = pq.count()
104
        count = pq.count()
105
        nb_max_projects = self.neighborhood.get_max_projects()
105
        projects = pq.skip(start).limit(int(limit)).all()
106
        projects = pq.skip(start).limit(int(limit)).all()
106
        categories = M.ProjectCategory.query.find({'parent_id':None}).sort('name').all()
107
        categories = M.ProjectCategory.query.find({'parent_id':None}).sort('name').all()
107
        c.custom_sidebar_menu = []
108
        c.custom_sidebar_menu = []
108
        if h.has_access(self.neighborhood, 'register')():
109
        if h.has_access(self.neighborhood, 'register')() and (nb_max_projects is None or count < nb_max_projects):
109
            c.custom_sidebar_menu += [
110
            c.custom_sidebar_menu += [
110
                SitemapEntry('Add a Project', self.neighborhood.url()+'add_project', ui_icon=g.icons['plus']),
111
                SitemapEntry('Add a Project', self.neighborhood.url()+'add_project', ui_icon=g.icons['plus']),
111
                SitemapEntry('')
112
                SitemapEntry('')
112
            ]
113
            ]
113
        c.custom_sidebar_menu = c.custom_sidebar_menu + [
114
        c.custom_sidebar_menu = c.custom_sidebar_menu + [
...
...
154
                 private_project=None, tools=None, **kw):
155
                 private_project=None, tools=None, **kw):
155
        require_access(self.neighborhood, 'register')
156
        require_access(self.neighborhood, 'register')
156
        if private_project:
157
        if private_project:
157
            require_access(self.neighborhood, 'admin')
158
            require_access(self.neighborhood, 'admin')
158
        neighborhood = M.Neighborhood.query.get(name=neighborhood)
159
        neighborhood = M.Neighborhood.query.get(name=neighborhood)
160
159
        project_description = h.really_unicode(project_description or '').encode('utf-8')
161
        project_description = h.really_unicode(project_description or '').encode('utf-8')
160
        project_name = h.really_unicode(project_name or '').encode('utf-8')
162
        project_name = h.really_unicode(project_name or '').encode('utf-8')
161
        project_unixname = h.really_unicode(project_unixname or '').encode('utf-8').lower()
163
        project_unixname = h.really_unicode(project_unixname or '').encode('utf-8').lower()
164
        try:
162
        c.project = neighborhood.register_project(project_unixname,
165
            c.project = neighborhood.register_project(project_unixname,
163
                project_name=project_name, private_project=private_project)
166
                    project_name=project_name, private_project=private_project)
167
        except exceptions.ProjectOverlimitError:
168
            flash("You have exceeded the maximum number of projects you are allowed to create", 'error')
169
            redirect('.')
170
164
        if project_description:
171
        if project_description:
165
            c.project.short_description = project_description
172
            c.project.short_description = project_description
166
        offset = c.project.next_mount_point(include_search=True)
173
        offset = c.project.next_mount_point(include_search=True)
167
        if tools and not neighborhood.project_template:
174
        if tools and not neighborhood.project_template:
168
            for i, tool in enumerate(tools):
175
            for i, tool in enumerate(tools):
...
...
246
        if app is None:
253
        if app is None:
247
            raise exc.HTTPNotFound, name
254
            raise exc.HTTPNotFound, name
248
        c.app = app
255
        c.app = app
249
        if not app.root:
256
        if not app.root:
250
            raise exc.HTTPNotFound, name
257
            raise exc.HTTPNotFound, name
258
251
        return app.root, remainder
259
        return app.root, remainder
252
260
253
    def _check_security(self):
261
    def _check_security(self):
254
        require_access(c.project, 'read')
262
        require_access(c.project, 'read')
255
263
...
...
456
        self.neighborhood.name = name
464
        self.neighborhood.name = name
457
        self.neighborhood.redirect = kw.pop('redirect', '')
465
        self.neighborhood.redirect = kw.pop('redirect', '')
458
        self.neighborhood.homepage = homepage
466
        self.neighborhood.homepage = homepage
459
        self.neighborhood.css = css
467
        self.neighborhood.css = css
460
        self.neighborhood.project_template = project_template
468
        self.neighborhood.project_template = project_template
461
        self.neighborhood.allow_browse = 'allow_browse' in kw
469
        self.neighborhood.allow_browse = kw.get('allow_browse', False)
462
        if icon is not None and icon != '':
470
        if icon is not None and icon != '':
463
            if self.neighborhood.icon:
471
            if self.neighborhood.icon:
464
                self.neighborhood.icon.delete()
472
                self.neighborhood.icon.delete()
465
            M.NeighborhoodFile.save_image(
473
            M.NeighborhoodFile.save_image(
466
                icon.filename, icon.file, content_type=icon.type,
474
                icon.filename, icon.file, content_type=icon.type,