hazelnut expects the initial columns to be passed to its constructor
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 26 Mar 2013 11:20:37 +0000 (12:20 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 26 Mar 2013 11:20:37 +0000 (12:20 +0100)
by default this amounts to the query's fields

auth/views.py
manifold/manifoldquery.py
plugins/hazelnut/hazelnut.html
plugins/hazelnut/hazelnut.js
plugins/hazelnut/hazelnut.py
trash/sliceview.py

index c26bc1d..2a9ff83 100644 (file)
@@ -44,7 +44,7 @@ def login_user(request):
 
 # hard question : where should we redirect requests to logout if user is not logged in ?
 def logout_user (request):
-    # xxx check that we're indeed logged in
+    # check that we're indeed logged in
     if not request.user.is_authenticated():
         return HttpResponseRedirect ('/')
     logout(request)
index 2ca4137..da3bbc5 100644 (file)
@@ -21,7 +21,7 @@ class ManifoldQuery:
         self.filters=filters
         self.params=params
         self.fields=fields
-        # xxx this is unused for now
+        # xxx these are unused for now....
         self.sort=sort
         self.limit=limit
         self.offset=offset
index f3b3573..196a387 100644 (file)
@@ -1,6 +1,6 @@
 <table class='display' id='hazelnut-{{ domid }}'>
-<thead><tr> {% for subject_field in subject_fields %}
-<th>{{ subject_field }}</th>{% endfor %} {% if checkboxes %}<th>+/-</th>{% endif %}
+<thead><tr> {% for column in columns %}
+<th>{{ column }}</th>{% endfor %} {% if checkboxes %}<th>+/-</th>{% endif %}
 </tr></thead>
 <tbody>
 </tbody>
index b1c095c..ca49146 100644 (file)
@@ -78,6 +78,7 @@
         show : function( ) {
            var $this=$(this);
            // xxx wtf. why [1] ? would expect 0...
+           if (debug) console.log("Hitting suspicious line in hazelnut.show");
             var oTable = $($('.dataTable', $this)[1]).dataTable();
             oTable.fnAdjustColumnSizing()
     
         this.options = options;
         /* constructor */
         this.table = null;
-       // xxx thierry : init this here - it was not, I expect this relied on set_query somehow..
+       // xxx thierry : initialize this here - it was not, I expect this relied on set_query somehow..
         //this.current_query = null;
        this.current_query=manifold.find_query(this.options.query_uuid);
        if (debug) console.log("Hazelnut constructor: have set current_query -> " + this.current_query);
             // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2
             aoColumnDefs: [{sDefaultContent: '',aTargets: [ '_all' ]}],
             bRetrieve: true,
-           // xxx this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty
+           // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty
             // sScrollX: '100%',       /* Horizontal scrolling */
             bProcessing: true,      /* Loading */
             fnRowCallback: function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
index a93c709..c46bfee 100644 (file)
@@ -2,10 +2,17 @@ from unfold.plugin import Plugin
 
 class Hazelnut (Plugin):
 
-    def __init__ (self, query, checkboxes=False, **settings):
+    # set checkboxes if a final column with checkboxes is desired
+    # pass columns as the initial set of columns
+    #   if None then this is taken from the query's fields
+    def __init__ (self, query, checkboxes=False, columns=None, **settings):
         Plugin.__init__ (self, **settings)
         self.query=query
         self.checkboxes=checkboxes
+        if columns is not None:
+            self.columns=columns
+        else:
+            self.columns=self.query.fields
 
     def template_file (self):
         return "hazelnut.html"
@@ -13,11 +20,7 @@ class Hazelnut (Plugin):
     def template_env (self, request):
         env={}
         env.update(self.__dict__)
-        # xxx need to retrieve metadata
-# $subject_keys = Plugins::get_default_fields($query->subject, $is_unique);
-# $fields = Plugins::metadata_get_fields($query->subject);
-# for now I am hard-coding the ones from haze.py
-        env['subject_fields']=[ 'network', 'type', 'hostname', 'hrn' ]
+        env['columns']=self.columns
         return env
 
     def requirements (self):
index 139dccd..d1c93dd 100644 (file)
@@ -71,6 +71,7 @@ def slice_view (request, slicename=tmp_default_slice):
 #                toggled=False,
                 # this is the query at the core of the slice list
                 query=main_query,
+                columns=['hrn','hostname'],
                 ),
               QueryCode (
                 page=page,