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,
9 checkboxes=False, columns=None,
10 datatables_options={}, **settings):
11 Plugin.__init__ (self, **settings)
13 # Until we have a proper way to access queries in Python
14 self.query_all = query_all
15 self.query_all_uuid = query_all.query_uuid if query_all else None
16 self.checkboxes = checkboxes
17 # XXX We need to have some hidden columns until we properly handle dynamic queries
18 if columns is not None:
20 self.hidden_columns = []
22 self.columns = self.query.fields
24 # We need a list because sets are not JSON-serilizable
25 self.hidden_columns = list(self.query_all.fields - self.query.fields)
27 self.hidden_columns = []
30 self.hidden_columns = []
31 self.datatables_options=datatables_options
33 def template_file (self):
34 return "hazelnut.html"
36 def template_env (self, request):
38 env.update(self.__dict__)
39 env['columns']=self.columns
42 def requirements (self):
44 'js_files' : [ "js/hazelnut.js",
45 "js/manifold.js", "js/manifold-query.js",
46 "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js",
47 "js/spin.presets.js", "js/spin.min.js", "js/jquery.spin.js",
48 "js/unfold-helper.js",
50 'css_files': [ "css/hazelnut.css" ,
51 "css/dataTables.bootstrap.css",
52 # hopefully temporary, when/if datatables supports sPaginationType=bootstrap3
53 # for now we use full_numbers\, with our own ad hoc css
54 "css/dataTables.full_numbers.css",
59 # the list of things passed to the js plugin
60 def json_settings_list (self):
61 return ['plugin_uuid', 'domid',
62 'query_uuid', 'query_all_uuid',
63 'checkboxes', 'datatables_options',