From 64be7f204b6f00244951821884a37fb74b3bbe36 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 22 Mar 2013 10:44:45 +0100 Subject: [PATCH] Plugin now has __repr__ tweak Composite to ensure it has exactly one active son add checkboxes=True to Hazelnut, although not tested.. slice view now has 2 hazelnuts in a tabs, with and without checkboxes --- myslice/viewutils.py | 2 +- plugins/hazelnut/hazelnut.html | 2 +- plugins/hazelnut/hazelnut.py | 3 ++- plugins/tabs/tabs.html | 5 ++--- plugins/tabs/tabs.py | 2 ++ trash/pluginview.py | 19 +++++++++++----- trash/sampleviews.py | 2 +- trash/sliceview.py | 35 +++++++++++++++++++++-------- trash/templates/view-tab.html | 4 ++-- unfold/composite.py | 29 ++++++++++++++++++------ unfold/plugin.py | 3 +++ views/templates/widget-topmenu.html | 2 +- 12 files changed, 76 insertions(+), 32 deletions(-) diff --git a/myslice/viewutils.py b/myslice/viewutils.py index 669c4ca4..29ee071a 100644 --- a/myslice/viewutils.py +++ b/myslice/viewutils.py @@ -16,7 +16,7 @@ standard_topmenu_items = [ def topmenu_items (current,request=None): result=deepcopy(standard_topmenu_items) for d in result: - if d['label'].lower().find(current)>=0: d['active']=True + if d['label'].lower().find(current)>=0: d['is_active']=True if not request: return result has_user=request.user.is_authenticated() # result.append (login_out_items [ has_user] ) diff --git a/plugins/hazelnut/hazelnut.html b/plugins/hazelnut/hazelnut.html index cbaac59b..f3b3573a 100644 --- a/plugins/hazelnut/hazelnut.html +++ b/plugins/hazelnut/hazelnut.html @@ -1,6 +1,6 @@ {% for subject_field in subject_fields %} -{% endfor %} +{% endfor %} {% if checkboxes %}{% endif %} diff --git a/plugins/hazelnut/hazelnut.py b/plugins/hazelnut/hazelnut.py index 60c9ec95..3d748e81 100644 --- a/plugins/hazelnut/hazelnut.py +++ b/plugins/hazelnut/hazelnut.py @@ -2,9 +2,10 @@ from unfold.plugin import Plugin class Hazelnut (Plugin): - def __init__ (self, query, **settings): + def __init__ (self, query, checkboxes=False, **settings): Plugin.__init__ (self, **settings) self.query=query + self.checkboxes=checkboxes def template_file (self): return "hazelnut.html" diff --git a/plugins/tabs/tabs.html b/plugins/tabs/tabs.html index 7c387d8f..cdf73acd 100644 --- a/plugins/tabs/tabs.html +++ b/plugins/tabs/tabs.html @@ -1,12 +1,11 @@ -{# could try to set class='active' on the one we want to highlight #}
{% for son in sons %} -
+
{{ son.rendered }}
{% endfor %} diff --git a/plugins/tabs/tabs.py b/plugins/tabs/tabs.py index 211af422..0350c264 100644 --- a/plugins/tabs/tabs.py +++ b/plugins/tabs/tabs.py @@ -10,3 +10,5 @@ class Tabs (Composite): def template_file (self): return "tabs.html" + # see Composite.py for the details of template_env, that exposes global + # 'sons' as a list of sons with each a set of a few attributes diff --git a/trash/pluginview.py b/trash/pluginview.py index a7269b96..c836c764 100644 --- a/trash/pluginview.py +++ b/trash/pluginview.py @@ -38,20 +38,27 @@ def test_plugin_view (request): toggled=False), Tabs (page=page, title='Sample Tabs', + domid='test-tabs', # *** we select this one to be the active tab *** - active='raw2', + active_domid='son2', sons = [ Raw (page=page, - title='a raw plugin',domid='raw1', + title='a raw plugin', + domid='son0', togglable=False, - html= 3*lorem_p), + html= 3*lorem_p, + ), StaticList(page=page, title='a slice list', + domid='son1', togglable=False, header="static list but not togglable", - list=hard_wired_slice_names), + list=hard_wired_slice_names, + ), Raw (page=page, - title='raw title',domid='raw2', - togglable=False,html=lorem) ]), + title='raw title', + domid='son2', + togglable=False, + html=lorem) ]), StaticList (page=page, title='SimpleList with slice names', list=hard_wired_slice_names, diff --git a/trash/sampleviews.py b/trash/sampleviews.py index 5e3c9420..e2687781 100644 --- a/trash/sampleviews.py +++ b/trash/sampleviews.py @@ -14,13 +14,13 @@ from myslice.viewutils import lorem, hard_wired_slice_names def tab_view (request): prelude=Prelude( js_files='js/bootstrap.js', css_files='css/bootstrap.css') prelude_env = prelude.prelude_env() + tab_env = {'title':'Page for playing with Tabs', 'topmenu_items': topmenu_items('tab',request), 'username':the_user (request), 'lorem': lorem, } tab_env.update (prelude_env) - return render_to_response ('view-tab.html', tab_env, context_instance=RequestContext(request)) diff --git a/trash/sliceview.py b/trash/sliceview.py index a410a71e..4f4202df 100644 --- a/trash/sliceview.py +++ b/trash/sliceview.py @@ -9,6 +9,7 @@ from unfold.page import Page from manifold.manifoldquery import ManifoldQuery from plugins.stack.stack import Stack +from plugins.tabs.tabs import Tabs from plugins.hazelnut.hazelnut import Hazelnut from plugins.lists.slicelist import SliceList from plugins.querycode.querycode import QueryCode @@ -41,20 +42,36 @@ def slice_view (request, slicename=tmp_default_slice): main_plugin = Stack ( page=page, title="global container", - sons=[ - Hazelnut ( # setting visible attributes first + togglable=False, + sons=[Tabs ( page=page, - title='a sample and simple hazelnut', - # this is the query at the core of the slice list - query=main_query, - ), - QueryCode ( + title="different angles", + active_domid='with-checkboxes', + sons=[ + Hazelnut ( + page=page, + title='a sample and simple hazelnut', + togglable=False, + # this is the query at the core of the slice list + query=main_query, + ), + Hazelnut ( + page=page, + title='with checkboxes', + domid='with-checkboxes', + togglable=False, + checkboxes=True, + # this is the query at the core of the slice list + query=main_query, + ), + ]), + QueryCode ( page=page, title='xmlrpc code', query=main_query, toggled=False, ), - ]) + ]) # variables that will get passed to the view-plugin.html template template_env = {} @@ -65,7 +82,7 @@ def slice_view (request, slicename=tmp_default_slice): # more general variables expected in the template template_env [ 'title' ] = 'Test view for hazelnut' # the menu items on the top - template_env [ 'topmenu_items' ] = topmenu_items('hazelnut', request) + template_env [ 'topmenu_items' ] = topmenu_items('slice', request) # so we can sho who is logged template_env [ 'username' ] = the_user (request) diff --git a/trash/templates/view-tab.html b/trash/templates/view-tab.html index 1e48e5c1..2cc6817a 100644 --- a/trash/templates/view-tab.html +++ b/trash/templates/view-tab.html @@ -4,7 +4,7 @@ {% insert_str prelude "css/sample.css" %} {% insert prelude_js %} -$(function(){console.log('hey!');$('#tooltipid').tooltip({'selector':'','placement':'bottom'});}); +$(function(){$('#tooltipid').tooltip({'selector':'','placement':'bottom'});}); {% endinsert %}
{{ subject_field }}{{ subject_field }}+/-