|
a/Allura/allura/controllers/project.py |
|
b/Allura/allura/controllers/project.py |
1 |
import os, re
|
1 |
import re
|
2 |
import logging
|
2 |
import logging
|
3 |
import json
|
|
|
4 |
|
3 |
|
5 |
from bson import ObjectId
|
4 |
from bson import ObjectId
|
6 |
from urllib import unquote, quote
|
5 |
from urllib import unquote
|
7 |
from urllib2 import urlopen
|
|
|
8 |
from itertools import chain, islice
|
6 |
from itertools import chain, islice
|
9 |
from cStringIO import StringIO
|
|
|
10 |
|
7 |
|
11 |
import pkg_resources
|
|
|
12 |
import Image
|
|
|
13 |
from tg import expose, flash, redirect, validate, request, response
|
8 |
from tg import expose, flash, redirect, validate, request, response
|
14 |
from tg.decorators import with_trailing_slash, without_trailing_slash
|
9 |
from tg.decorators import with_trailing_slash, without_trailing_slash
|
15 |
from pylons import c, g
|
10 |
from pylons import c, g
|
16 |
from paste.httpheaders import CACHE_CONTROL
|
|
|
17 |
from webob import exc
|
11 |
from webob import exc
|
18 |
from bson import ObjectId
|
|
|
19 |
import pymongo
|
12 |
import pymongo
|
20 |
from formencode import validators
|
13 |
from formencode import validators
|
21 |
|
14 |
|
22 |
import ming.orm.ormsession
|
|
|
23 |
from ming.utils import LazyProperty
|
15 |
from ming.utils import LazyProperty
|
24 |
|
16 |
|
25 |
import allura
|
|
|
26 |
from allura import model as M
|
17 |
from allura import model as M
|
27 |
from allura.app import SitemapEntry
|
18 |
from allura.app import SitemapEntry
|
28 |
from allura.lib.base import WsgiDispatchController
|
19 |
from allura.lib.base import WsgiDispatchController
|
29 |
from allura.lib import helpers as h
|
20 |
from allura.lib import helpers as h
|
30 |
from allura.lib import utils
|
21 |
from allura.lib import utils
|
31 |
from allura.lib.decorators import require_post
|
22 |
from allura.lib.decorators import require_post
|
32 |
from allura.controllers.error import ErrorController
|
23 |
from allura.controllers.error import ErrorController
|
33 |
from allura.lib.security import require_access, has_access
|
24 |
from allura.lib.security import require_access, has_access
|
34 |
from allura.lib.security import RoleCache
|
25 |
from allura.lib.security import RoleCache
|
|
|
26 |
from allura.lib.widgets import forms as ff
|
35 |
from allura.lib.widgets import form_fields as ffw
|
27 |
from allura.lib.widgets import form_fields as ffw
|
36 |
from allura.lib.widgets import project_list as plw
|
28 |
from allura.lib.widgets import project_list as plw
|
37 |
from allura.lib import plugin
|
29 |
from allura.lib import plugin
|
38 |
from allura.lib import exceptions as forge_exc
|
|
|
39 |
from .auth import AuthController
|
30 |
from .auth import AuthController
|
40 |
from .search import SearchController, ProjectBrowseController
|
31 |
from .search import SearchController, ProjectBrowseController
|
41 |
from .static import NewForgeController
|
32 |
from .static import NewForgeController
|
42 |
|
|
|
43 |
from allura.model.session import main_orm_session
|
|
|
44 |
|
33 |
|
45 |
log = logging.getLogger(__name__)
|
34 |
log = logging.getLogger(__name__)
|
46 |
|
35 |
|
47 |
class W:
|
36 |
class W:
|
48 |
resize_editor = ffw.AutoResizeTextarea()
|
37 |
resize_editor = ffw.AutoResizeTextarea()
|
49 |
project_summary = plw.ProjectSummary()
|
38 |
project_summary = plw.ProjectSummary()
|
50 |
add_project = plugin.ProjectRegistrationProvider.get().add_project_widget(antispam=True)
|
39 |
add_project = plugin.ProjectRegistrationProvider.get().add_project_widget(antispam=True)
|
51 |
page_list = ffw.PageList()
|
40 |
page_list = ffw.PageList()
|
52 |
page_size = ffw.PageSize()
|
41 |
page_size = ffw.PageSize()
|
53 |
project_select = ffw.NeighborhoodProjectSelect
|
42 |
project_select = ffw.NeighborhoodProjectSelect
|
|
|
43 |
neighborhood_overview_form = ff.NeighborhoodOverviewForm()
|
54 |
|
44 |
|
55 |
class NeighborhoodController(object):
|
45 |
class NeighborhoodController(object):
|
56 |
'''Manages a neighborhood of projects.
|
46 |
'''Manages a neighborhood of projects.
|
57 |
'''
|
47 |
'''
|
58 |
|
48 |
|
|
... |
|
... |
406 |
require_access(self.neighborhood, 'admin')
|
396 |
require_access(self.neighborhood, 'admin')
|
407 |
utils.permanent_redirect('overview')
|
397 |
utils.permanent_redirect('overview')
|
408 |
|
398 |
|
409 |
@without_trailing_slash
|
399 |
@without_trailing_slash
|
410 |
@expose('jinja:allura:templates/neighborhood_admin_overview.html')
|
400 |
@expose('jinja:allura:templates/neighborhood_admin_overview.html')
|
411 |
def overview(self):
|
401 |
def overview(self, **kw):
|
412 |
require_access(self.neighborhood, 'admin')
|
402 |
require_access(self.neighborhood, 'admin')
|
413 |
set_nav(self.neighborhood)
|
403 |
set_nav(self.neighborhood)
|
414 |
c.resize_editor = W.resize_editor
|
404 |
c.overview_form = W.neighborhood_overview_form
|
415 |
return dict(neighborhood=self.neighborhood)
|
405 |
return dict(neighborhood=self.neighborhood)
|
416 |
|
406 |
|
417 |
@without_trailing_slash
|
407 |
@without_trailing_slash
|
418 |
@expose('jinja:allura:templates/neighborhood_admin_permissions.html')
|
408 |
@expose('jinja:allura:templates/neighborhood_admin_permissions.html')
|
419 |
def permissions(self):
|
409 |
def permissions(self):
|
|
... |
|
... |
455 |
grants_count=grants_count,
|
445 |
grants_count=grants_count,
|
456 |
neighborhood=self.neighborhood)
|
446 |
neighborhood=self.neighborhood)
|
457 |
|
447 |
|
458 |
@expose()
|
448 |
@expose()
|
459 |
@require_post()
|
449 |
@require_post()
|
|
|
450 |
@validate(W.neighborhood_overview_form, error_handler=overview)
|
460 |
def update(self, name=None, css=None, homepage=None, project_template=None, icon=None, **kw):
|
451 |
def update(self, name=None, css=None, homepage=None, project_template=None, icon=None, **kw):
|
461 |
require_access(self.neighborhood, 'admin')
|
452 |
require_access(self.neighborhood, 'admin')
|
462 |
self.neighborhood.name = name
|
453 |
self.neighborhood.name = name
|
463 |
self.neighborhood.redirect = kw.pop('redirect', '')
|
454 |
self.neighborhood.redirect = kw.pop('redirect', '')
|
464 |
self.neighborhood.homepage = homepage
|
455 |
self.neighborhood.homepage = homepage
|
|
... |
|
... |
471 |
M.NeighborhoodFile.save_image(
|
462 |
M.NeighborhoodFile.save_image(
|
472 |
icon.filename, icon.file, content_type=icon.type,
|
463 |
icon.filename, icon.file, content_type=icon.type,
|
473 |
square=True, thumbnail_size=(48,48),
|
464 |
square=True, thumbnail_size=(48,48),
|
474 |
thumbnail_meta=dict(neighborhood_id=self.neighborhood._id))
|
465 |
thumbnail_meta=dict(neighborhood_id=self.neighborhood._id))
|
475 |
redirect('overview')
|
466 |
redirect('overview')
|
|
|
467 |
|
476 |
|
468 |
|
477 |
class NeighborhoodModerateController(object):
|
469 |
class NeighborhoodModerateController(object):
|
478 |
|
470 |
|
479 |
def __init__(self, neighborhood):
|
471 |
def __init__(self, neighborhood):
|
480 |
self.neighborhood = neighborhood
|
472 |
self.neighborhood = neighborhood
|