[components] Fix selector to avoid empty left nav column
authorVincent Michel <vincent.michel@logilab.fr>
Tue, 16 Jul 2013 16:31:49 +0200
changeset 304 d59f33992acb
parent 303 5b7153bafd9e
child 305 7f2926b4049e
[components] Fix selector to avoid empty left nav column
views/components.py
views/download.py
--- a/views/components.py	Tue Jul 16 16:24:50 2013 +0200
+++ b/views/components.py	Tue Jul 16 16:31:49 2013 +0200
@@ -28,6 +28,9 @@
 from cubicweb.web.views.basecomponents import ApplicationName
 
 from cubes.brainomics import COMMENTED_ENTITIES, WIKI_ENTITIES
+from cubes.brainomics.views.download import ALL_DOWNLOADABLE
+
+LINKED_ENTITIES = ('Subject',)
 
 
 ################################################################################
@@ -70,6 +73,7 @@
     context = 'left'
     __regid__ = 'links-ctx'
     order = 1
+    __select__ = component.EntityCtxComponent.__select__ & is_instance(*LINKED_ENTITIES)
 
     def render(self, w, **kwargs):
         links = list(self._cw.vreg['ctx-related-links'].possible_objects(self._cw, rset=self.cw_rset))
@@ -168,6 +172,7 @@
 class BrainomicsEditBox(EditBox):
     context = 'left'
     order = -10
+    __select__ = EditBox.__select__ & match_user_groups('users', 'managers')
 
     def init_rendering(self):
         pass
@@ -198,7 +203,7 @@
 ### DOWNLOAD BOX ##############################################################
 ###############################################################################
 class BrainomicsDownloadBox(component.CtxComponent):
-    __select__ = component.CtxComponent.__select__ & nonempty_rset()
+    __select__ = component.CtxComponent.__select__ & nonempty_rset() & is_instance(*ALL_DOWNLOADABLE)
     context = 'left'
     order = 1
     __regid__ = 'ctx-download-box'
--- a/views/download.py	Tue Jul 16 16:24:50 2013 +0200
+++ b/views/download.py	Tue Jul 16 16:31:49 2013 +0200
@@ -33,6 +33,7 @@
                     'Answer', 'GenomicMeasure', 'Snp')
 XCEDE_DOWNLOADABLE = ('Subject', 'Scan', 'GenomicMeasure', 'QuestionnaireRun', 'Questionnaire')
 ZIP_DOWNLOADABLE = ('Scan', 'GenomicMeasure')
+ALL_DOWNLOADABLE = set(CSV_DOWNLOADABLE + XCEDE_DOWNLOADABLE + ZIP_DOWNLOADABLE)
 
 
 ###############################################################################