From 5e1a278283582937b13f5f757d88dd50b37e52ed Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 26 Mar 2013 12:20:37 +0100 Subject: [PATCH] hazelnut expects the initial columns to be passed to its constructor by default this amounts to the query's fields --- auth/views.py | 2 +- manifold/manifoldquery.py | 2 +- plugins/hazelnut/hazelnut.html | 4 ++-- plugins/hazelnut/hazelnut.js | 5 +++-- plugins/hazelnut/hazelnut.py | 15 +++++++++------ trash/sliceview.py | 1 + 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/auth/views.py b/auth/views.py index c26bc1d0..2a9ff836 100644 --- a/auth/views.py +++ b/auth/views.py @@ -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) diff --git a/manifold/manifoldquery.py b/manifold/manifoldquery.py index 2ca41373..da3bbc5d 100644 --- a/manifold/manifoldquery.py +++ b/manifold/manifoldquery.py @@ -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 diff --git a/plugins/hazelnut/hazelnut.html b/plugins/hazelnut/hazelnut.html index f3b3573a..196a387b 100644 --- a/plugins/hazelnut/hazelnut.html +++ b/plugins/hazelnut/hazelnut.html @@ -1,6 +1,6 @@ - {% for subject_field in subject_fields %} -{% endfor %} {% if checkboxes %}{% endif %} + {% for column in columns %} +{% endfor %} {% if checkboxes %}{% endif %} diff --git a/plugins/hazelnut/hazelnut.js b/plugins/hazelnut/hazelnut.js index b1c095cb..ca491460 100644 --- a/plugins/hazelnut/hazelnut.js +++ b/plugins/hazelnut/hazelnut.js @@ -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() @@ -104,7 +105,7 @@ 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); @@ -127,7 +128,7 @@ // 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 ) { diff --git a/plugins/hazelnut/hazelnut.py b/plugins/hazelnut/hazelnut.py index a93c709e..c46bfeef 100644 --- a/plugins/hazelnut/hazelnut.py +++ b/plugins/hazelnut/hazelnut.py @@ -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): diff --git a/trash/sliceview.py b/trash/sliceview.py index 139dccd7..d1c93dd0 100644 --- a/trash/sliceview.py +++ b/trash/sliceview.py @@ -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, -- 2.43.0
{{ subject_field }}+/-
{{ column }}+/-