9dfebf11e48ff07c7800d90f7fa0c28b65533352
[myslice.git] / plugins / hazelnut / hazelnut.py
1 from unfold.plugin import Plugin
2
3 class Hazelnut (Plugin):
4
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, checkboxes=False, columns=None, datatables_options={}, **settings):
9         Plugin.__init__ (self, **settings)
10         self.query=query
11         self.checkboxes=checkboxes
12         if columns is not None:
13             self.columns=columns
14         else:
15             self.columns=self.query.fields
16         self.datatables_options=datatables_options
17
18     def template_file (self):
19         return "hazelnut.html"
20
21     def template_env (self, request):
22         env={}
23         env.update(self.__dict__)
24         env['columns']=self.columns
25         return env
26
27     def requirements (self):
28         reqs = {
29             'js_files' : [ "js/hazelnut.js", 
30                            "js/manifold.js", "js/manifold-query.js", 
31                            "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js",
32                            "js/spin.presets.js", "js/spin.min.js", "js/jquery.spin.js", 
33                            "js/unfold-helper.js",
34                            ] ,
35             'css_files': [ "css/hazelnut.css" , 
36                            "css/dataTables.bootstrap.css",
37                            ],
38             }
39         return reqs
40
41     # the list of things passed to the js plugin
42     def json_settings_list (self): return ['plugin_uuid', 'domid', 'query_uuid','checkboxes','datatables_options']