[PATCH skos] Allow to override how concepts are rendered in ConceptScheme tab view

Frank Bessou frank.bessou at logilab.fr
Thu Sep 27 16:07:27 CEST 2018


# HG changeset patch
# User Frank Bessou <frank.bessou at logilab.fr>
# Date 1538042661 -7200
#      Thu Sep 27 12:04:21 2018 +0200
# Node ID 624e90196f4c029f54112d129a96d7f11aeabb45
# Parent  68cd0ac0693b83d86328261abb3f06a96f921bbb
# Available At http://hg.logilab.org/review/cubes/skos
#              hg pull http://hg.logilab.org/review/cubes/skos -r 624e90196f4c
Allow to override how concepts are rendered in ConceptScheme tab view

In SAEM we need to render the concept tree as a jquery tree. So we
introduce a render_tree method intended to be overidden by specific
cubes.

diff --git a/cubicweb_skos/views/__init__.py b/cubicweb_skos/views/__init__.py
--- a/cubicweb_skos/views/__init__.py
+++ b/cubicweb_skos/views/__init__.py
@@ -153,6 +153,11 @@ class ConceptSchemeConceptsTab(tabs.Tabs
     __regid__ = 'skos_top_concepts_tab'  # don't use '.' in tab's regid
     __select__ = is_instance('ConceptScheme')
 
+    def render_tree(self, entity, children_rset):
+        treeid = 'skos_tree_%s' % entity.eid
+        self._cw.view('treeview', rset=children_rset, treeid=treeid,
+                      initial_thru_ajax=True, w=self.w)
+
     def entity_call(self, entity):
         rschema = self._cw.vreg.schema.rschema('in_scheme')
         if rschema.has_perm(self._cw, 'add', toeid=entity.eid):
@@ -164,8 +169,7 @@ class ConceptSchemeConceptsTab(tabs.Tabs
         if not rset:
             return
         if len(rset) < self._cw.property_value('navigation.page-size'):
-            treeid = 'skos_tree_%s' % entity.eid
-            self._cw.view('treeview', rset=rset, treeid=treeid, initial_thru_ajax=True, w=self.w)
+            self.render_tree(entity, rset)
         else:
             self._cw.view('paginated-list', rset=rset, w=self.w)
 



More information about the saem-devel mailing list