1 from unfold.plugin import Plugin
3 # lists levels and sets them to enabled or not at startup
4 default_levels = {'fatal': True, 'error': True, 'warning' : True, 'info' : True, 'debug' : False}
6 # there are two implementations available here
7 # one shows up in the main page like a regular part of the page,
8 # while the other one relies on transient popups
9 # by default we use the latter, but you can specify
10 # transient=False if you want to use the former
12 # also the pieces that go with this transient mode are
13 # under views/templates, it would make sense to move them over here
14 # however it turns out that views/templates/base.html unconditionnally
15 # includes messages-transient-header.html
16 class Messages (Plugin):
18 def __init__ (self, transient=True, levels=None, **settings):
19 Plugin.__init__ (self, **settings)
20 if levels is None: levels=default_levels
21 # shortcut: 'ALL' turn everything on
22 elif levels=='ALL': levels=dict( [ (k,True) for k in default_levels ] )
23 elif levels=='NONE': levels=dict( [ (k,False) for k in default_levels ] )
24 self.transient=transient
27 def template_file (self):
28 return "messages.html" if not self.transient else "messages-transient.html"
30 def requirements (self):
32 'js_files' : [ "js/messages.js", "js/manifold.js", ],
33 'css_files' : "css/messages.css",
36 # although this has no query, we need a plugin instance to be created in the js output
37 def export_json_settings (self):
39 # the js plugin expects a domid
40 def json_settings_list (self):
41 return [ 'plugin_uuid', 'levels' ]
43 # and we don't need a spin wheel
44 def start_with_spin (self):