from plugins.simplelist import SimpleList
-from myslice.viewutils import menu_items, the_user
+from myslice.viewutils import menu_items, the_user, hard_wired_slice_names
def test_plugin_view (request):
- test_plugin = SimpleList (visible=True, hidable=True)
- plugin_content = test_plugin.render (request)
+ hard_wired_list=[]
+ hard_wired_list.append("this hard-wired list")
+ hard_wired_list.append("is defined")
+ hard_wired_list.append("in <code>plugins.simplelist.py</code>")
+ hard_wired_list.append("which in turn relies on")
+ hard_wired_list.append("template <code>widget-template.html</code>")
+ hard_wired_list.append("while it should of course")
+ hard_wired_list.append("instead issue a query")
+ hard_wired_list.append("and fill the DOM in js from there")
+ hard_wired_list.append("it would however maybe make sense")
+ hard_wired_list.append("to offer the option to 'datatablify'")
+ hard_wired_list.append("the list from the python code")
+ hard_wired_list.append("just like a standard plugin can be set as visible or not")
+ hard_wired_list.append("")
+ hard_wired_list.append("OTOH and IMHO, there should be two separate and explicit subclasses of SimpleList for slices or testbeds")
- print '--------------------'
- print plugin_content
- print '--------------------'
+ plugin_main = SimpleList (visible=True, hidable=True, list=hard_wired_list, header='Hard wired')
+ content_main = plugin_main.render (request)
+
+ # lacks a/href to /slice/%s
+ plugin_related = SimpleList (visible=True, hidable=True,
+ need_datatables='yes',
+ list=hard_wired_slice_names, header='Slices' )
+ content_related = plugin_related.render (request)
+
+
return render_to_response ('view-plugin.html',
{'title': 'Test Plugin View',
'menu_items': menu_items('plugin', request),
- 'content_main' : plugin_content,
+ 'content_main' : content_main,
+ 'content_related' : content_related,
'username' : the_user (request),
},
context_instance=RequestContext(request))
class SimpleList (Plugin) :
def render_content (self, request):
- return render_to_string ("widget-simplelist.html",{})
+ return render_to_string ("widget-simplelist.html",
+ self._settings)
--- /dev/null
+select {
+ width: auto;
+}
--- /dev/null
+/* elements with class 'need-datatables' are set to use datatables */
+$(document).ready(function() {$('.need-datatables').each(function() { $(this).dataTable() } ) } )
* };
*/
-$(document).ready(
- function() {
- $('.plugin-hide').each(function(p) {
- plugin='#'+$(this).attr('id').replace('hide-','plugin-');
- show='#'+$(this).attr('id').replace('hide-','show-');
- type=$(this).attr('plugin-type');
- $(this).click(function () { jQuery(plugin).hide(); jQuery(show).show(); $(this).hide();})
+$(document).ready(function() {
+ $('.plugin-hide').each(function() {
+ window.console.log ('@load: id='+$(this).attr('id'));
+ $(this).click(function () {
+ var plugin='#'+$(this).attr('id').replace('hide-','plugin-');
+ var show='#'+$(this).attr('id').replace('hide-','show-');
+ window.console.log ("Hiding:"+$(this).attr('id')+' plugin='+plugin+' show='+show);
+ jQuery(plugin).hide(); jQuery(show).show(); $(this).hide();});
})
- $('.plugin-show').each(function(p) {
- plugin='#'+$(this).attr('id').replace('show-','plugin-');
- hide='#'+$(this).attr('id').replace('show-','hide-');
- type=$(this).attr('plugin-type');
- $(this).click(function () { jQuery(plugin).show(); jQuery(hide).show(); $(this).hide();})
+ $('.plugin-show').each(function() {
+ window.console.log ('@load: id='+$(this).attr('id'));
+ $(this).click(function () {
+ var plugin='#'+$(this).attr('id').replace('show-','plugin-');
+ var hide='#'+$(this).attr('id').replace('show-','hide-');
+ window.console.log ("Showing:"+$(this).attr('id')+' plugin='+plugin+' hide='+hide);
+ jQuery(plugin).show(); jQuery(hide).show(); $(this).hide();});
})
- })
-
-
+ })
{% extends 'layout-myslice.html' %}
{% block content_main %}
-{{ content_main }}
+{{ content_main|safe }}
{% endblock content_main %}
+
+{% block content_related %}
+{% insert_str prelude "datatables/js/dataTables.js" %}
+{% insert_str prelude "js/need-datatables.js" %}
+{% insert_str prelude "css/simplelist.css" %}
+
+{{ content_related|safe }}
+{% endblock content_related %}
+{# -*-django-html-mumamo-mode-*- #}
{% extends 'layout-myslice.html' %}
{% block content_main %}
$(document).ready(function () { $('#datatable').dataTable() } )
{% endinsert %}
-<table id='datatable'>
- <thead> <tr> <th>slice</th> </tr> </thead>
- <tbody>
- {% for slicename in slices %}
- <tr><td> <a href="/slice/{{ slicename }}/">{{ slicename }}</a></td></tr>
- {% endfor %}
- </tbody>
-</table>
{% endblock content_related %}
{% endif %}
{% endif %}
-<div class='plugin {{ title }}' id='plugin-{{ uuid }}' plugin-type='{{ title }}'>
+<div class='plugin {{ title }}' id='plugin-{{ uuid }}'>
{{ plugin_content|safe }}
</div><!--plugin {{ title }}-->
-<ul>
-<li>this hard-wired list</li>
-<li>is defined</li>
-<li>in <code>plugins.simplelist.py</code></li>
-<li>which in turn relies on</li>
-<li>template <code>widget-template.html</code></li>
-<li>while it should of course</li>
-<li>instead issue a query</li>
-<li>and fill the DOM in js from there</li>
-<li>it would however maybe make sense</li>
-<li>to offer the option to 'datatablify'</li>
-<li>the list from the python code</li>
-<li>just like a standard plugin can be set as visible or not</li>
-<li />
-<li>OTOH and IMHO, there should be two separate and explicit subclasses of SimpleList for slices or testbeds</li>
-</ul>
+<table class='simplelist {%if need_datatables %}need-datatables{% endif %}'>
+{% if header %}
+<thead><tr><th>{{ header }}</th></tr></thead>
+{% endif %}
+<tbody>
+{% for item in list %}
+<tr><td>{{ item }}</td></tr>
+{% endfor %}
+</tbody>
+</table>