[saem-devel] [PATCH 05 of 10 sherpa] Ensure security management action has a consistent selector with the security view

Sylvain Thenault sylvain.thenault at logilab.fr
Thu Feb 23 09:32:54 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1487798691 -3600
#      Wed Feb 22 22:24:51 2017 +0100
# Node ID 4d836625fe3f05d624245e2a0ec0053c403fce2f
# Parent  a3d5446bb9ee09dd11340b127ee58d344ac9dea9
Ensure security management action has a consistent selector with the security view

diff --git a/views/management.py b/views/management.py
--- a/views/management.py
+++ b/views/management.py
@@ -14,22 +14,22 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 from logilab.mtconverter import xml_escape
 
-from cubicweb.predicates import relation_possible
-from cubicweb.web import formwidgets
+from cubicweb.predicates import relation_possible, one_line_rset, non_final_entity
+from cubicweb.web import action, formwidgets
 from cubicweb.web.formfields import guess_field
-from cubicweb.web.views.management import SecurityManagementView
+from cubicweb.web.views import actions, management
 
 from cubes.relationwidget.views import RelationFacetWidget
 
 
-class SherpaSecurityManagementView(SecurityManagementView):
+class SherpaSecurityManagementView(management.SecurityManagementView):
     """Security view overriden to hide permissions definitions and using a
     RelationFacetWidget to edit owner"""
-    __select__ = (SecurityManagementView.__select__ &
+    __select__ = (management.SecurityManagementView.__select__ &
                   relation_possible('owned_by', action='add'))
 
     def entity_call(self, entity):
         w = self.w
         w(u'<h1><span class="etype">%s</span> <a href="%s">%s</a></h1>'
@@ -51,8 +51,13 @@ class SherpaSecurityManagementView(Secur
                             widget=RelationFacetWidget())
         form.append_field(field)
         form.render(w=w, display_progress_div=False)
 
 
+actions.ManagePermissionsAction.__select__ = (
+    action.Action.__select__ & one_line_rset() & non_final_entity()
+    & relation_possible('owned_by', action='add'))
+
+
 def registration_callback(vreg):
     vreg.register_all(globals().values(), __name__)
-    vreg.unregister(SecurityManagementView)
+    vreg.unregister(management.SecurityManagementView)


More information about the saem-devel mailing list