should add relation_possible selector only if require_permission is in the schema tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 17 Feb 2009 20:47:22 +0100
branchtls-sprint
changeset 690 ea613e8a5e4f
parent 689 a9d9421d1be0
child 693 cf0817dfc787
should add relation_possible selector only if require_permission is in the schema
web/views/actions.py
--- a/web/views/actions.py	Tue Feb 17 20:46:43 2009 +0100
+++ b/web/views/actions.py	Tue Feb 17 20:47:22 2009 +0100
@@ -126,17 +126,19 @@
 
 # generic secondary actions ###################################################
 
-class ManagePermissions(Action):
+class ManagePermissionsAction(Action):
     id = 'addpermission'
-    __selectors__ = (
-        (match_user_groups('managers') 
-         | relation_possible('require_permission', 'subject', 'EPermission')),
-                   )
+    __selectors__ = match_user_groups('managers') 
 
     title = _('manage permissions')
     category = 'moreactions'
     order = 100
-    
+
+    def registered(cls, vreg):
+        if 'require_permission' in vreg.schema:
+            cls.__selectors__ |= relation_possible('require_permission', 'subject', 'EPermission',
+                                                   action='add')
+            
     def url(self):
         return self.rset.get_entity(0, 0).absolute_url(vid='security')
 
@@ -269,4 +271,3 @@
     
     def url(self):
         return self.build_url(self.id)
-