|
@@ -95,7 +95,8 @@ class PODUserFilteredApiController(object):
|
95
|
95
|
def createNode(self, parent_id=0):
|
96
|
96
|
loNode = pbmd.PBNode()
|
97
|
97
|
loNode.owner_id = self._iCurrentUserId
|
98
|
|
- loNode.parent_id = parent_id
|
|
98
|
+ if int(parent_id)!=0:
|
|
99
|
+ loNode.parent_id = parent_id
|
99
|
100
|
parent_rights = DBSession.query(pbma.Rights).filter(pbma.Rights.node_id==parent_id).all()
|
100
|
101
|
loNode.rights = parent_rights
|
101
|
102
|
loNode.rights = [pbma.Rights(group_id=r.group_id, rights=r.rights) for r in parent_rights]
|
|
@@ -124,7 +125,7 @@ class PODUserFilteredApiController(object):
|
124
|
125
|
"""
|
125
|
126
|
lsNodeIdFiltering = lsSqlSelectQuery % (str(self._iCurrentUserId))
|
126
|
127
|
|
127
|
|
- if liNodeId!=0:
|
|
128
|
+ if liNodeId!=None and liNodeId!=0:
|
128
|
129
|
return DBSession.query(pbmd.PBNode).options(joinedload_all("_lAllChildren"))\
|
129
|
130
|
.filter(pbmd.PBNode.node_id==liNodeId)\
|
130
|
131
|
.filter(
|
|
@@ -174,7 +175,19 @@ class PODUserFilteredApiController(object):
|
174
|
175
|
def buildTreeListForMenu(self, plViewableStatusId):
|
175
|
176
|
liOwnerIdList = self._getUserIdListForFiltering()
|
176
|
177
|
|
177
|
|
- loNodeList = pbm.DBSession.query(pbmd.PBNode).filter(pbmd.PBNode.owner_id.in_(liOwnerIdList)).filter(pbmd.PBNode.node_type==pbmd.PBNodeType.Data).filter(pbmd.PBNode.node_status.in_(plViewableStatusId)).order_by(pbmd.PBNode.parent_tree_path).order_by(pbmd.PBNode.node_order).order_by(pbmd.PBNode.node_id).all()
|
|
178
|
+ # loNodeList = pbm.DBSession.query(pbmd.PBNode).filter(pbmd.PBNode.owner_id.in_(liOwnerIdList)).filter(pbmd.PBNode.node_type==pbmd.PBNodeType.Data).filter(pbmd.PBNode.node_status.in_(plViewableStatusId)).order_by(pbmd.PBNode.parent_tree_path).order_by(pbmd.PBNode.node_order).order_by(pbmd.PBNode.node_id).all()
|
|
179
|
+ loNodeListNotFiltered = pbm.DBSession.query(pbmd.PBNode).filter(pbmd.PBNode.node_type==pbmd.PBNodeType.Data).filter(pbmd.PBNode.node_status.in_(plViewableStatusId)).order_by(pbmd.PBNode.parent_tree_path).order_by(pbmd.PBNode.node_order).order_by(pbmd.PBNode.node_id).all()
|
|
180
|
+
|
|
181
|
+ loNodeList = []
|
|
182
|
+ for loNode in loNodeListNotFiltered:
|
|
183
|
+ if loNode.owner_id in self._getUserIdListForFiltering():
|
|
184
|
+ loNodeList.append(loNode)
|
|
185
|
+ else:
|
|
186
|
+ for loRight in loNode._lRights:
|
|
187
|
+ for loUser in loRight._oGroup.users:
|
|
188
|
+ if loUser.user_id in self._getUserIdListForFiltering():
|
|
189
|
+ loNodeList.append(loNode)
|
|
190
|
+
|
178
|
191
|
loTreeList = []
|
179
|
192
|
loTmpDict = {}
|
180
|
193
|
for loNode in loNodeList:
|
|
@@ -189,8 +202,18 @@ class PODUserFilteredApiController(object):
|
189
|
202
|
# We suppose that the parent node has already been added
|
190
|
203
|
# this *should* be the case, but the code does not check it
|
191
|
204
|
if loNode.parent_id not in loTmpDict.keys():
|
192
|
|
- loTmpDict[loNode.parent_id] = self.getNode(loNode.parent_id)
|
193
|
|
- loTmpDict[loNode.parent_id].appendStaticChild(loNode)
|
|
205
|
+ print('THE NODE =========',loNode.parent_id)
|
|
206
|
+ try:
|
|
207
|
+ loTmpDict[loNode.parent_id] = self.getNode(loNode.parent_id)
|
|
208
|
+ except Exception as e:
|
|
209
|
+ # loTreeList.append(
|
|
210
|
+ # FIXME - D.A. - 2014-05-22 This may be wrong code:
|
|
211
|
+ # we are in the case when the node parent is not shared with the current user
|
|
212
|
+ # So the node should be added at the root
|
|
213
|
+ pass
|
|
214
|
+ if loNode.parent_id in loTmpDict.keys():
|
|
215
|
+ # HACK- D.A. - 2014-05-22 - See FIXME upper
|
|
216
|
+ loTmpDict[loNode.parent_id].appendStaticChild(loNode)
|
194
|
217
|
|
195
|
218
|
return loTreeList
|
196
|
219
|
|