1 # Create your views here.
3 from django.core.context_processors import csrf
4 from django.template import RequestContext
5 from django.template.loader import render_to_string
6 from django.shortcuts import render_to_response
8 from django.contrib.auth.decorators import login_required
10 from unfold.page import Page
11 from manifold.core.query import Query
13 from plugins.stack import Stack
14 from plugins.tabs import Tabs
15 from plugins.lists.staticlist import StaticList
16 from plugins.quickfilter import QuickFilter
17 from plugins.querycode import QueryCode
18 from plugins.raw import Raw
19 from plugins.messages import Messages
20 from plugins.querytable import QueryTable
22 from ui.topmenu import topmenu_items_live, the_user
23 from trashutils import hard_wired_slice_names, hard_wired_list, lorem_p, lorem, quickfilter_criterias
25 #might be useful or not depending on the context
27 def test_plugin_view (request):
31 page.expose_js_metadata()
33 # variables that will get passed to this template
36 slicename='ple.inria.heartbeat'
37 main_query = Query.get('resource').filter_by('slice_hrn', '=', slicename).select(['network','type','hrn','hostname','sliver'])
38 # without an querytable, this would use use : run_it=False as nothing would listen to the results
39 page.enqueue_query (main_query, # run_it=False
49 # make sure the 2 things work together
52 title="Transient Runtime messages",
53 domid="messages-transient",
58 title="Slice %s - checkboxes"%slicename,
66 title="Inline Runtime messages",
74 title="issue messages",
77 <input type="button" id="bouton" value="Click me" />
82 page.add_js_chunks ( """
83 function issue_debug() {console.log("issue_debug");messages.debug("issue_debug");};
84 $(function(){$("#bouton").click(issue_debug);});
87 # define 'unfold_main' to the template engine
88 template_env [ 'unfold_main' ] = main_plugin.render(request)
90 # more general variables expected in the template
91 template_env [ 'title' ] = 'Single Plugin View'
92 template_env [ 'topmenu_items' ] = topmenu_items_live('plugin', page)
93 template_env [ 'username' ] = the_user (request)
95 # the prelude object in page contains a summary of the requirements() for all plugins
96 # define {js,css}_{files,chunks}
97 prelude_env = page.prelude_env()
98 template_env.update(prelude_env)
99 return render_to_response ('view-unfold1.html',template_env,
100 context_instance=RequestContext(request))