Browse Source

use node_id instead of node as url parameter

Damien Accorsi 10 years ago
parent
commit
6e5cf574cb
2 changed files with 17 additions and 15 deletions
  1. 2 2
      pboard/pboard/controllers/root.py
  2. 15 13
      pboard/pboard/lib/auth.py

+ 2 - 2
pboard/pboard/controllers/root.py View File

@@ -116,13 +116,13 @@ class RootController(BaseController):
116 116
     @expose('pboard.templates.document')
117 117
     #@require(predicates.in_group('user', msg=l_('Please login to access this page')))
118 118
     @require(can_read())
119
-    def document(self, node=0, version=0, came_from=lurl('/'), highlight=''):
119
+    def document(self, node_id=0, version=0, came_from=lurl('/'), highlight=''):
120 120
         """show the user dashboard"""
121 121
         loCurrentUser   = pld.PODStaticController.getCurrentUser()
122 122
         loApiController = pld.PODUserFilteredApiController(loCurrentUser.user_id)
123 123
 
124 124
         loRootNodeList = loApiController.buildTreeListForMenu(pbmd.PBNodeStatus.getVisibleIdsList())
125
-        liNodeId         = int(node)
125
+        liNodeId         = int(node_id)
126 126
         liVersionId      = int(version)
127 127
 
128 128
         loCurrentNode    = None

+ 15 - 13
pboard/pboard/lib/auth.py View File

@@ -11,8 +11,8 @@ class can_read(Predicate):
11 11
         pass
12 12
 
13 13
     def evaluate(self, environ, credentials):
14
-        if 'node' in environ['webob.adhoc_attrs']['validation']['values']:
15
-            node_id = environ['webob.adhoc_attrs']['validation']['values']['node']
14
+        if 'node_id' in environ['webob.adhoc_attrs']['validation']['values']:
15
+            node_id = environ['webob.adhoc_attrs']['validation']['values']['node_id']
16 16
             if node_id!=0:
17 17
                 has_right = session.execute("""
18 18
                         select *
@@ -32,15 +32,17 @@ class can_write(Predicate):
32 32
         pass
33 33
 
34 34
     def evaluate(self, environ, credentials):
35
-        node_id = environ['webob.adhoc_attrs']['validation']['values']['node_id']
36
-        has_right = session.execute("""
37
-                select *
38
-                from pod_group_node pgn
39
-                join pod_user_group pug on pug.group_id = pgn.group_id
40
-                join pod_user pu on pug.user_id = pu.user_id
41
-                where rights > 1
42
-                and email_address = :mail
43
-                and node_id = :node""", {"mail":credentials["repoze.who.userid"], "node":node_id})
44
-        if has_right.rowcount == 0 :
45
-            self.unmet()
35
+        if 'node_id' in environ['webob.adhoc_attrs']['validation']['values']:
36
+            node_id = environ['webob.adhoc_attrs']['validation']['values']['node_id']
37
+            if node_id!=0:
38
+                has_right = session.execute("""
39
+                        select *
40
+                        from pod_group_node pgn
41
+                        join pod_user_group pug on pug.group_id = pgn.group_id
42
+                        join pod_user pu on pug.user_id = pu.user_id
43
+                        where rights > 1
44
+                        and email_address = :mail
45
+                        and node_id = :node""", {"mail":credentials["repoze.who.userid"], "node":node_id})
46
+                if has_right.rowcount == 0 :
47
+                    self.unmet()
46 48