|
a/Allura/allura/model/project.py |
|
b/Allura/allura/model/project.py |
|
... |
|
... |
53 |
return self.query.get(_id=self.parent_id)
|
53 |
return self.query.get(_id=self.parent_id)
|
54 |
|
54 |
|
55 |
@property
|
55 |
@property
|
56 |
def subcategories(self):
|
56 |
def subcategories(self):
|
57 |
return self.query.find(dict(parent_id=self._id)).all()
|
57 |
return self.query.find(dict(parent_id=self._id)).all()
|
|
|
58 |
|
|
|
59 |
class TroveCategory(MappedClass):
|
|
|
60 |
class __mongometa__:
|
|
|
61 |
session = main_orm_session
|
|
|
62 |
name='trove_category'
|
|
|
63 |
indexes = [ 'trove_cat_id', 'trove_parent_id' ]
|
|
|
64 |
|
|
|
65 |
_id=FieldProperty(S.ObjectId)
|
|
|
66 |
trove_cat_id = FieldProperty(int, if_missing=None)
|
|
|
67 |
trove_parent_id = FieldProperty(int, if_missing=None)
|
|
|
68 |
shortname = FieldProperty(str, if_missing='')
|
|
|
69 |
fullname = FieldProperty(str, if_missing='')
|
|
|
70 |
fullpath = FieldProperty(str, if_missing='')
|
|
|
71 |
|
|
|
72 |
@property
|
|
|
73 |
def parent_category(self):
|
|
|
74 |
return self.query.get(trove_cat_id=self.trove_parent_id)
|
|
|
75 |
|
|
|
76 |
@property
|
|
|
77 |
def subcategories(self):
|
|
|
78 |
return self.query.find(dict(trove_parent_id=self.trove_cat_id)).sort('fullname').all()
|
58 |
|
79 |
|
59 |
class Project(MappedClass):
|
80 |
class Project(MappedClass):
|
60 |
_perms_base = [ 'read', 'update', 'admin', 'create']
|
81 |
_perms_base = [ 'read', 'update', 'admin', 'create']
|
61 |
_perms_init = _perms_base + [ 'register' ]
|
82 |
_perms_init = _perms_base + [ 'register' ]
|
62 |
class __mongometa__:
|
83 |
class __mongometa__:
|
|
... |
|
... |
98 |
last_updated = FieldProperty(datetime, if_missing=None)
|
119 |
last_updated = FieldProperty(datetime, if_missing=None)
|
99 |
tool_data = FieldProperty({str:{str:None}}) # entry point: prefs dict
|
120 |
tool_data = FieldProperty({str:{str:None}}) # entry point: prefs dict
|
100 |
ordinal = FieldProperty(int, if_missing=0)
|
121 |
ordinal = FieldProperty(int, if_missing=0)
|
101 |
database_configured = FieldProperty(bool, if_missing=True)
|
122 |
database_configured = FieldProperty(bool, if_missing=True)
|
102 |
_extra_tool_status = FieldProperty([str])
|
123 |
_extra_tool_status = FieldProperty([str])
|
|
|
124 |
trove_root_database=FieldProperty([S.ObjectId])
|
|
|
125 |
trove_developmentstatus=FieldProperty([S.ObjectId])
|
|
|
126 |
trove_audience=FieldProperty([S.ObjectId])
|
|
|
127 |
trove_license=FieldProperty([S.ObjectId])
|
|
|
128 |
trove_os=FieldProperty([S.ObjectId])
|
|
|
129 |
trove_language=FieldProperty([S.ObjectId])
|
|
|
130 |
trove_topic=FieldProperty([S.ObjectId])
|
|
|
131 |
trove_natlanguage=FieldProperty([S.ObjectId])
|
|
|
132 |
trove_environment=FieldProperty([S.ObjectId])
|
103 |
|
133 |
|
104 |
@property
|
134 |
@property
|
105 |
def permissions(self):
|
135 |
def permissions(self):
|
106 |
if self.shortname == '--init--':
|
136 |
if self.shortname == '--init--':
|
107 |
return self._perms_init
|
137 |
return self._perms_init
|
|
... |
|
... |
135 |
result.append(SitemapEntry('Child Projects'))
|
165 |
result.append(SitemapEntry('Child Projects'))
|
136 |
result += [
|
166 |
result += [
|
137 |
SitemapEntry(p.name or p.script_name, p.script_name)
|
167 |
SitemapEntry(p.name or p.script_name, p.script_name)
|
138 |
for p in sps ]
|
168 |
for p in sps ]
|
139 |
return result
|
169 |
return result
|
|
|
170 |
|
|
|
171 |
def troves_by_type(self, trove_type):
|
|
|
172 |
return TroveCategory.query.find({'_id':{'$in':getattr(self,'trove_%s' % trove_type)}}).all()
|
140 |
|
173 |
|
141 |
def get_tool_data(self, tool, key, default=None):
|
174 |
def get_tool_data(self, tool, key, default=None):
|
142 |
return self.tool_data.get(tool, {}).get(key, None)
|
175 |
return self.tool_data.get(tool, {}).get(key, None)
|
143 |
|
176 |
|
144 |
def set_tool_data(self, tool, **kw):
|
177 |
def set_tool_data(self, tool, **kw):
|