1 from unfold.plugin import Plugin
3 class Hazelnut (Plugin):
5 # set checkboxes if a final column with checkboxes is desired
6 # pass columns as the initial set of columns
7 # if None then this is taken from the query's fields
8 def __init__ (self, query=None, query_all=None, checkboxes=False, columns=None, datatables_options={}, **settings):
9 Plugin.__init__ (self, **settings)
11 # Until we have a proper way to access queries in Python
12 self.query_all = query_all
13 self.query_all_uuid = query_all.query_uuid if query_all else None
14 self.checkboxes=checkboxes
15 # XXX We need to have some hidden columns until we properly handle dynamic queries
16 if columns is not None:
18 self.hidden_columns = []
20 self.columns = self.query.fields
22 # We need a list because sets are not JSON-serilizable
23 self.hidden_columns = list(self.query_all.fields - self.query.fields)
25 self.hidden_columns = []
28 self.hidden_columns = []
29 self.datatables_options=datatables_options
31 def template_file (self):
32 return "hazelnut.html"
34 def template_env (self, request):
36 env.update(self.__dict__)
37 env['columns']=self.columns
40 def requirements (self):
42 'js_files' : [ "js/hazelnut.js",
43 "js/manifold.js", "js/manifold-query.js",
44 "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js",
45 "js/spin.presets.js", "js/spin.min.js", "js/jquery.spin.js",
46 "js/unfold-helper.js",
48 'css_files': [ "css/hazelnut.css" ,
49 "css/dataTables.bootstrap.css",
54 # the list of things passed to the js plugin
55 def json_settings_list (self):
56 return ['plugin_uuid', 'domid', 'query_uuid', 'query_all_uuid', 'checkboxes', 'datatables_options', 'hidden_columns']