don't show add new action for composed objects
authorSylvain Thenault <sylvain.thenault@logilab.fr>
Mon, 05 Jan 2009 16:56:48 +0100
changeset 328 02abf429dd91
parent 327 239cc0c3a5e4
child 329 903eb8c4ebd6
don't show add new action for composed objects
web/views/actions.py
--- a/web/views/actions.py	Mon Jan 05 16:43:54 2009 +0100
+++ b/web/views/actions.py	Mon Jan 05 16:56:48 2009 +0100
@@ -160,15 +160,17 @@
                 return 0
             select = rqlst.children[0]
             if len(select.defined_vars) == 1 and len(select.solutions) == 1:
-                    rset._searched_etype = select.solutions[0].itervalues().next()
-                    eschema = cls.schema.eschema(rset._searched_etype)
-                    if not eschema.is_final() and eschema.has_perm(req, 'add'):
-                        return 1
+                rset._searched_etype = select.solutions[0].itervalues().next()
+                eschema = cls.schema.eschema(rset._searched_etype)
+                if not (eschema.is_final() or eschema.is_subobject(strict=True)) \
+                       and eschema.has_perm(req, 'add'):
+                    return 1
         return 0
 
     def has_add_perm_selector(cls, req, rset, **kwargs):
         eschema = cls.schema.eschema(rset.description[0][0])
-        if not eschema.is_final() and eschema.has_perm(req, 'add'):
+        if not (eschema.is_final() or eschema.is_subobject(strict=True)) \
+               and eschema.has_perm(req, 'add'):
             return 1
         return 0
     __selectors__ = (match_search_state,