[views] Add facets
authorVincent Michel <vincent.michel@logilab.fr>
Tue, 11 Dec 2012 18:12:54 +0100
changeset 8 776e19aab816
parent 7 b790dac9b452
child 9 9f8abd6d251e
[views] Add facets
views/facets.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/facets.py	Tue Dec 11 18:12:54 2012 +0100
@@ -0,0 +1,75 @@
+
+from cubicweb.web import facet
+from cubicweb.selectors import is_instance
+
+import cubes.simplefacet.views as newfacet
+
+
+############################################################################
+### SUBJECT FACETS #########################################################
+############################################################################
+class SubjectEtypeFacet(facet.RQLPathFacet):
+    __regid__ = 'subject-etype-facet'
+    __select__ = is_instance('Subject')
+    order = 0
+    path = ['M concerns X', 'M is_instance_of T', 'T name N']
+    filter_variable = 'N'
+    title = _('Available Measures')
+
+class SubjectGenderFacet(facet.AttributeFacet):
+    __regid__ = 'subject-gender-facet'
+    __select__ = facet.AttributeFacet.__select__ & is_instance('Subject')
+    order = 1
+    rtype = 'gender'
+    title = _('Gender')
+
+class SubjectHandednessFacet(facet.AttributeFacet):
+    __regid__ = 'subject-handedness-facet'
+    __select__ = facet.AttributeFacet.__select__ & is_instance('Subject')
+    order = 2
+    rtype = 'handedness'
+    title = _('Handedness')
+
+class SubjectAgeFacet(facet.AttributeFacet):
+    __regid__ = 'subject-age-facet'
+    __select__ = facet.AttributeFacet.__select__ & is_instance('Subject')
+    rtype = 'age'
+    title = _('Age')
+    support_and = True
+
+
+############################################################################
+### MEASURE FACETS #########################################################
+############################################################################
+class MeasureEtypeFacet(facet.RQLPathFacet):
+    __regid__ = 'measure-etype-facet'
+    # this facet should only be selected when visualizing offices
+    __select__ = is_instance('Scan', 'QuestionnaireRun', 'GenomicMeasure')
+    path = ['X concerns S', 'M concerns S', 'M is_instance_of T', 'T name N']
+    order = 0
+    filter_variable = 'N'
+    title = _('Available Measures')
+
+class MeasureAgeFacet(facet.RQLPathFacet):
+    __regid__ = 'measure-age-facet'
+    __select__ = is_instance('Scan', 'QuestionnaireRun', 'GenomicMeasure')
+    path = ['X concerns S', 'S age A']
+    order = 1
+    filter_variable = 'A'
+    title = _("Subject Age")
+
+class MeasureHandednessFacet(facet.RQLPathFacet):
+    __regid__ = 'measure-handedness-facet'
+    __select__ = is_instance('Scan', 'QuestionnaireRun', 'GenomicMeasure')
+    path = ['X concerns S', 'S handedness A']
+    order = 2
+    filter_variable = 'A'
+    title = _('Subject Handedness')
+
+class MeasureGenderFacet(facet.RQLPathFacet):
+    __regid__ = 'measure-gender-facet'
+    __select__ = is_instance('Scan', 'QuestionnaireRun', 'GenomicMeasure')
+    path = ['X concerns S', 'S gender A']
+    order = 3
+    filter_variable = 'A'
+    title = _('Subject Gender')