fix box selectors tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 18 Feb 2009 16:03:11 +0100
branchtls-sprint
changeset 809 31962f99770b
parent 808 8d739f6e8ef5
child 810 154bf8cfd65b
fix box selectors
web/box.py
web/views/boxes.py
--- a/web/box.py	Wed Feb 18 16:02:44 2009 +0100
+++ b/web/box.py	Wed Feb 18 16:03:11 2009 +0100
@@ -37,7 +37,7 @@
         box.render(self.w)
     """
     __registry__ = 'boxes'
-    __select__ = Template.__select__ & match_context_prop()
+    __select__ = match_context_prop()
     
     categories_in_order = ()
     property_defs = {
@@ -135,7 +135,7 @@
 
 class EntityBoxTemplate(BoxTemplate):
     """base class for boxes related to a single entity"""
-    __select__ = one_line_rset() & primary_view() & match_context_prop()
+    __select__ = BoxTemplate.__select__ & one_line_rset() & primary_view()
     registered = accepts_compat(has_relation_compat(condition_compat(BoxTemplate.registered)))
     context = 'incontext'
     
--- a/web/views/boxes.py	Wed Feb 18 16:02:44 2009 +0100
+++ b/web/views/boxes.py	Wed Feb 18 16:03:11 2009 +0100
@@ -17,7 +17,7 @@
 
 from logilab.mtconverter import html_escape
 
-from cubicweb.selectors import any_rset, appobject_selectable, match_user_groups
+from cubicweb.selectors import (any_rset, appobject_selectable, match_user_groups, non_final_entity)
 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem
 from cubicweb.web.box import BoxTemplate
 
@@ -29,7 +29,7 @@
     box with all actions impacting the entity displayed: edit, copy, delete
     change state, add related entities
     """
-    __select__ = any_rset() & BoxTemplate.__select__
+    __select__ = BoxTemplate.__select__ & non_final_entity()
     id = 'edit_box'
     title = _('actions')
     order = 2
@@ -133,6 +133,7 @@
 class SearchBox(BoxTemplate):
     """display a box with a simple search form"""
     id = 'search_box'
+
     visible = True # enabled by default
     title = _('search')
     order = 0
@@ -146,7 +147,6 @@
 </td></tr></table>
 </form>"""
 
-
     def call(self, view=None, **kwargs):
         req = self.req
         if req.form.pop('__fromsearchbox', None):
@@ -166,11 +166,11 @@
 class PossibleViewsBox(BoxTemplate):
     """display a box containing links to all possible views"""
     id = 'possible_views_box'
-    __select__ = match_user_groups('users', 'managers')
+    __select__ = BoxTemplate.__select__ & match_user_groups('users', 'managers')
     
+    visible = False
     title = _('possible views')
     order = 10
-    visible = False
 
     def call(self, **kwargs):
         box = BoxWidget(self.req._(self.title), self.id)
@@ -191,8 +191,8 @@
     __select__ = (BoxTemplate.__select__
                   & appobject_selectable('components', 'rss_feed_url'))
     
+    visible = False
     order = 999
-    visible = False
     
     def call(self, **kwargs):
         try:
@@ -208,6 +208,7 @@
 class StartupViewsBox(BoxTemplate):
     """display a box containing links to all startup views"""
     id = 'startup_views_box'
+
     visible = False # disabled by default
     title = _('startup views')
     order = 70