Browse Source

current_user_rights now take correctly real groups in account

sferot 11 years ago
parent
commit
ebd30a5bb6
2 changed files with 14 additions and 4 deletions
  1. 1 4
      pboard/pboard/controllers/root.py
  2. 13 0
      pboard/pboard/lib/dbapi.py

+ 1 - 4
pboard/pboard/controllers/root.py View File

143
 
143
 
144
         user_specific_group_rights = pld.PODStaticController.getUserDedicatedGroupRightsOnNode(loCurrentNode)
144
         user_specific_group_rights = pld.PODStaticController.getUserDedicatedGroupRightsOnNode(loCurrentNode)
145
 
145
 
146
-        current_user_rights = None
147
-        for right in user_specific_group_rights:
148
-            if right.group_id == -loCurrentUser.user_id:
149
-                current_user_rights = right
146
+        current_user_rights = pld.PODStaticController.DIRTY_get_rights_on_node(loCurrentUser.user_id, loCurrentNode.node_id)
150
 
147
 
151
         return dict(
148
         return dict(
152
             current_user=loCurrentUser,
149
             current_user=loCurrentUser,

+ 13 - 0
pboard/pboard/lib/dbapi.py View File

153
 
153
 
154
     return group_rights_on_node
154
     return group_rights_on_node
155
 
155
 
156
+  @classmethod
157
+  def DIRTY_get_rights_on_node(self, user_id, node_id):
158
+      rights = pbm.DBSession\
159
+              .execute("""select max(rights) as rights
160
+                      from pod_user_group
161
+                      natural join pod_group_node
162
+                      where node_id=:node_id
163
+                      and user_id=:user_id""", {"node_id":node_id, "user_id":user_id})\
164
+              .fetchone()
165
+      r = pbmd.DIRTY_GroupRightsOnNode()
166
+      r.rights = rights[0]
167
+      return r
168
+
156
 
169
 
157
 
170
 
158
 class PODUserFilteredApiController(object):
171
 class PODUserFilteredApiController(object):