|
a/Allura/allura/model/project.py |
|
b/Allura/allura/model/project.py |
|
... |
|
... |
9 |
from bson import ObjectId
|
9 |
from bson import ObjectId
|
10 |
|
10 |
|
11 |
from ming import schema as S
|
11 |
from ming import schema as S
|
12 |
from ming.utils import LazyProperty
|
12 |
from ming.utils import LazyProperty
|
13 |
from ming.orm import ThreadLocalORMSession
|
13 |
from ming.orm import ThreadLocalORMSession
|
14 |
from ming.orm import session, state
|
14 |
from ming.orm import session, state, MapperExtension
|
15 |
from ming.orm import FieldProperty, RelationProperty, ForeignIdProperty
|
15 |
from ming.orm import FieldProperty, RelationProperty, ForeignIdProperty
|
16 |
from ming.orm.declarative import MappedClass
|
16 |
from ming.orm.declarative import MappedClass
|
17 |
|
17 |
|
18 |
from allura.lib import helpers as h
|
18 |
from allura.lib import helpers as h
|
19 |
from allura.lib import plugin
|
19 |
from allura.lib import plugin
|
|
... |
|
... |
76 |
return self.query.get(trove_cat_id=self.trove_parent_id)
|
76 |
return self.query.get(trove_cat_id=self.trove_parent_id)
|
77 |
|
77 |
|
78 |
@property
|
78 |
@property
|
79 |
def subcategories(self):
|
79 |
def subcategories(self):
|
80 |
return self.query.find(dict(trove_parent_id=self.trove_cat_id)).sort('fullname').all()
|
80 |
return self.query.find(dict(trove_parent_id=self.trove_cat_id)).sort('fullname').all()
|
|
|
81 |
|
|
|
82 |
class ProjectMapperExtension(MapperExtension):
|
|
|
83 |
def after_insert(self, obj, st):
|
|
|
84 |
g.zarkov_event('project_create', user=c.user, project=obj)
|
81 |
|
85 |
|
82 |
class Project(MappedClass):
|
86 |
class Project(MappedClass):
|
83 |
_perms_base = [ 'read', 'update', 'admin', 'create']
|
87 |
_perms_base = [ 'read', 'update', 'admin', 'create']
|
84 |
_perms_init = _perms_base + [ 'register' ]
|
88 |
_perms_init = _perms_base + [ 'register' ]
|
85 |
class __mongometa__:
|
89 |
class __mongometa__:
|
|
... |
|
... |
90 |
'neighborhood_id',
|
94 |
'neighborhood_id',
|
91 |
('neighborhood_id', 'name'),
|
95 |
('neighborhood_id', 'name'),
|
92 |
'shortname',
|
96 |
'shortname',
|
93 |
'parent_id',
|
97 |
'parent_id',
|
94 |
('deleted', 'shortname', 'neighborhood_id')]
|
98 |
('deleted', 'shortname', 'neighborhood_id')]
|
|
|
99 |
extensions = [ ProjectMapperExtension ]
|
95 |
|
100 |
|
96 |
# Project schema
|
101 |
# Project schema
|
97 |
_id=FieldProperty(S.ObjectId)
|
102 |
_id=FieldProperty(S.ObjectId)
|
98 |
parent_id = FieldProperty(S.ObjectId, if_missing=None)
|
103 |
parent_id = FieldProperty(S.ObjectId, if_missing=None)
|
99 |
neighborhood_id = ForeignIdProperty(Neighborhood)
|
104 |
neighborhood_id = ForeignIdProperty(Neighborhood)
|