From: Thierry Parmentelat Date: Mon, 11 Mar 2013 16:26:17 +0000 (+0100) Subject: rough staticlist : you provide a list, no query/no asynchroneous X-Git-Tag: myslice-django-0.1-1~34 X-Git-Url: http://git.onelab.eu/?p=unfold.git;a=commitdiff_plain;h=d5637be0b917439ebcc34c2c377efe2e9b1241e1 rough staticlist : you provide a list, no query/no asynchroneous probably not a high practical interest but for the sake of the design and also the views we have so far --- diff --git a/plugins/static/css/simplelist.css b/plugins/static/css/simplelist.css index 9ec90734..8bfe2167 100644 --- a/plugins/static/css/simplelist.css +++ b/plugins/static/css/simplelist.css @@ -1,9 +1,4 @@ -select { - width: auto; -} -div.dataTables_filter input[type=text] { - width: 60; -} +/* ---------- */ td.simplelist { padding: 0; list-style: none; @@ -14,3 +9,11 @@ td.simplelist>a { th.simplelist { font-size: 150%; } +/* ---------- */ +/* xxx this probably should be separated in something related to datatables */ +select { + width: auto; +} +div.dataTables_filter input[type=text] { + width: 60; +} diff --git a/plugins/static/css/staticlist.css b/plugins/static/css/staticlist.css new file mode 100644 index 00000000..226e1892 --- /dev/null +++ b/plugins/static/css/staticlist.css @@ -0,0 +1,3 @@ +th.staticlist { + font-size: 150%; +} diff --git a/plugins/staticlist.py b/plugins/staticlist.py new file mode 100644 index 00000000..b9c644b6 --- /dev/null +++ b/plugins/staticlist.py @@ -0,0 +1,29 @@ +from engine.plugin import Plugin + +class StaticList (Plugin) : + + # only deal with our own stuff here and let Plugin handle the rest + def __init__ (self, list=[], with_datatables=False, **settings): + Plugin.__init__ (self, **settings) + self.list=list + self.with_datatables = with_datatables + + # SimpleList is useless per se anyways + def template_file (self): + return "staticlist.html" + + def template_env (self, request): + env={} + header=getattr(self,'header',None) + if header: env['header']=header + env['list']=self.list + return env + + def requirements (self): + reqs = { 'js_files' : [ ] , + 'css_files': [ "css/staticlist.css" ], + } + if self.with_datatables: + reqs['js_files'].append ("datatables/js/dataTables.js") + reqs['js_files'].append ("js/with-datatables.js") + return reqs diff --git a/plugins/templates/simplelist.html b/plugins/templates/simplelist.html index 4132c4c7..ca30c0cb 100644 --- a/plugins/templates/simplelist.html +++ b/plugins/templates/simplelist.html @@ -3,8 +3,5 @@ {{ header }} {% endif %} -{% for item in list %} -{{ item|safe }} -{% endfor %} diff --git a/plugins/templates/staticlist.html b/plugins/templates/staticlist.html new file mode 100644 index 00000000..2e30eeec --- /dev/null +++ b/plugins/templates/staticlist.html @@ -0,0 +1,10 @@ + +{% if header %} + +{% endif %} + +{% for item in list %} + +{% endfor %} + +
{{ header }}
{{ item|safe }}
diff --git a/trash/pluginview.py b/trash/pluginview.py index e0bc2183..fa3336fa 100644 --- a/trash/pluginview.py +++ b/trash/pluginview.py @@ -11,8 +11,7 @@ from engine.pluginset import PluginSet from plugins.verticallayout import VerticalLayout from plugins.tabs import Tabs -from plugins.simplelist import SimpleList -from plugins.slicelist import SliceList +from plugins.staticlist import StaticList from plugins.quickfilter import QuickFilter from plugins.raw import Raw @@ -30,10 +29,10 @@ def test_plugin_view (request): main_plugin = \ VerticalLayout ( pluginset=pluginset, title='title for the vertical layout', - sons = [ SimpleList (pluginset=pluginset, - title='SimpleList and dataTables', + sons = [ StaticList (pluginset=pluginset, + title='StaticList - with datatables - starts toggled off', list=hard_wired_list, - header='Hard wired', + header='Hard wired header', foo='the value for foo', with_datatables=True, toggled=False), @@ -45,14 +44,15 @@ def test_plugin_view (request): title='a raw plugin',domid='raw1', togglable=False, html= 3*lorem_p), - SliceList(pluginset=pluginset, - title='a slice list', - togglable=False, - list=hard_wired_slice_names), + StaticList(pluginset=pluginset, + title='a slice list', + togglable=False, + header="static list but not togglable", + list=hard_wired_slice_names), Raw (pluginset=pluginset, title='raw title',domid='raw2', togglable=False,html=lorem) ]), - SimpleList (pluginset=pluginset, + StaticList (pluginset=pluginset, title='SimpleList with slice names', list=hard_wired_slice_names, ), @@ -64,11 +64,11 @@ def test_plugin_view (request): ########## # lacks a/href to /slice/%s - related_plugin = SliceList (pluginset=pluginset, - title='SliceList plugin',domid='slicelist1', - with_datatables='yes', - list=hard_wired_slice_names, - header='Slices') + related_plugin = StaticList (pluginset=pluginset, + title='SliceList plugin',domid='slicelist1', + with_datatables='yes', + list=hard_wired_slice_names, + header='Slices') # likewise but on the side view template_env [ 'content_related' ] = related_plugin.render (request)