1 from unfold.plugin import Plugin
3 from myslice.settings import logger
5 class UnivbrisVtam (Plugin):
6 def __init__ (self, query=None, query_all=None, sync_query=None,
7 checkboxes=False, columns=None,
9 datatables_options={}, **settings):
10 Plugin.__init__ (self, **settings)
12 self.query_uuid = query.query_uuid if query else None
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.sync_query_uuid = sync_query.query_uuid if sync_query else None
17 self.checkboxes = checkboxes
18 # XXX We need to have some hidden columns until we properly handle dynamic queries
19 if columns is not None:
21 self.hidden_columns = []
23 self.columns = list (['Testbed', 'Virtualization Server', 'VM name', 'Delete'])
25 #self.columns = self.query.fields
28 self.hidden_columns = []
29 # We need a list because sets are not JSON-serializable
30 #self.hidden_columns = #list(self.query_all.fields - self.query.fields)
32 self.hidden_columns = []
35 self.hidden_columns = []
37 self.columns = list (['Testbed', 'Virtualization Server', 'VM name', 'Delete'])
38 self.init_key=init_key
39 self.datatables_options=datatables_options
40 # if checkboxes were required, we tell datatables about this column's type
41 # so that sorting can take place on a selected-first basis (or -last of course)
42 # this relies on the template exposing the checkboxes 'th' with class 'checkbox'
44 # we use aoColumnDefs rather than aoColumns -- ignore user-provided aoColumns
45 if 'aoColumns' in self.datatables_options:
46 logger.warning('WARNING: querytable uses aoColumnDefs, your aoColumns spec. is discarded')
47 del self.datatables_options['aoColumns']
48 # set aoColumnDefs in datatables_options - might already have stuff in there
49 aoColumnDefs = self.datatables_options.setdefault ('aoColumnDefs',[])
50 # here 'checkbox' is the class that we give to the <th> dom elem
51 # dom-checkbox is a sorting type that we define in querytable.js
52 aoColumnDefs.append ( {'aTargets': ['checkbox'], 'sSortDataType': 'dom-checkbox' } )
54 def template_file (self):
55 return "univbrisvtamplugin.html"
57 def template_env (self, request):
59 env.update(self.__dict__)
60 env['columns']=self.columns
63 def requirements (self):
65 'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js",
66 "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js", "js/jquery.jeditable.js",
67 "js/manifold.js", "js/manifold-query.js",
68 "js/unfold-helper.js",
71 'css_files': [ "css/dataTables.bootstrap.css",
72 "css/dataTables.full_numbers.css",
73 "css/univbrisvtam.css",
78 def json_settings_list (self):
79 return ['plugin_uuid', 'domid',
80 'query_uuid', 'query_all_uuid', 'sync_query_uuid',
81 'checkboxes', 'datatables_options',
82 'hidden_columns', 'init_key',]