X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fmessages%2Fmessages.py;h=65baea1503dd7d705ae3bc542cb19c011ff8cdc1;hb=c7866026c1b4605f68dfd58cb91a53c874663b64;hp=dd1373d6c47d68f783c61d5f74d16777b9e984f7;hpb=4e4ba52a8bde99ef10f8fd33f7cf273e3d34a9a1;p=myslice.git diff --git a/plugins/messages/messages.py b/plugins/messages/messages.py index dd1373d6..65baea15 100644 --- a/plugins/messages/messages.py +++ b/plugins/messages/messages.py @@ -1,12 +1,31 @@ from unfold.plugin import Plugin +# lists levels and sets them to enabled or not at startup +default_levels = {'fatal': True, 'error': True, 'warning' : True, 'info' : True, 'debug' : False} + +# there are two implementations available here +# one shows up in the main page like a regular part of the page, +# while the other one relies on transient popups +# by default we use the latter, but you can specify +# transient=False if you want to use the former +# xxx +# also the pieces that go with this transient mode are +# under views/templates, it would make sense to move them over here +# however it turns out that views/templates/base.html unconditionnally +# includes messages-transient-header.html class Messages (Plugin): - def __init__ (self, **settings): + def __init__ (self, transient=True, levels=None, **settings): Plugin.__init__ (self, **settings) + if levels is None: levels=default_levels + # shortcut: 'ALL' turn everything on + elif levels=='ALL': levels=dict( [ (k,True) for k in default_levels ] ) + elif levels=='NONE': levels=dict( [ (k,False) for k in default_levels ] ) + self.transient=transient + self.levels=levels def template_file (self): - return "messages.html" + return "messages.html" if not self.transient else "messages-transient.html" def requirements (self): return { @@ -19,7 +38,7 @@ class Messages (Plugin): return True # the js plugin expects a domid def json_settings_list (self): - return [ 'plugin_uuid' ] + return [ 'plugin_uuid', 'levels' ] # and we don't need a spin wheel def start_with_spin (self):