Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
[myslice.git] / plugins / apply / __init__.py
1 from unfold.plugin import Plugin
2 from plugins.queryupdater import QueryUpdaterPlugin
3
4 class ApplyPlugin(Plugin):
5     
6     def __init__ (self, query=None, **settings):
7         Plugin.__init__ (self, **settings)
8         self.query              = query
9
10     def template_file (self):
11         return "apply.html"
12
13     def template_env(self, request):
14         query_updater = QueryUpdaterPlugin(
15             page                = self.page,
16             title               = 'Pending operations',
17             query               = self.query,
18             togglable           = False,
19             # start turned off, it will open up itself when stuff comes in
20             toggled             = True,
21             domid               = 'pending',
22             outline_complete    = True,
23             username            = request.user, # XXX ???
24         )
25
26         env = Plugin.template_env(self, request)
27         env.update({'query_updater': query_updater.render(request)})
28         return env
29
30     def requirements (self):
31         reqs = {
32             'js_files' : [
33                 'js/apply.js'
34             ],
35             'css_files' : [
36                 'css/apply.css'
37             ],
38         }
39         return reqs
40
41     def json_settings_list (self):
42         # query_uuid will pass self.query results to the javascript
43         # and will be available as "record" in :
44         # on_new_record: function(record)
45         return ['plugin_uuid', 'domid', 'query_uuid']
46
47     def export_json_settings (self):
48         return True