X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sandbox%2Fviews.py;h=6e1e152598d6090c67b91158338cf10cfda70ec8;hb=b07f4e9d842b3e4c59d5599be7445e45b819a547;hp=dda1771889915ea1d1a1c6296055d08851a10309;hpb=5de3330b8219f03bc53d9bbace764ee3912e6017;p=myslice.git
diff --git a/sandbox/views.py b/sandbox/views.py
index dda17718..6e1e1525 100644
--- a/sandbox/views.py
+++ b/sandbox/views.py
@@ -26,14 +26,13 @@ import json
from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import render
from django.template.loader import render_to_string
-
+from manifold.core.query import Query
+from plugins.myplugin import MyPlugin
+from plugins.maddash import MadDash
+from ui.topmenu import topmenu_items_live, the_user
from unfold.loginrequired import FreeAccessView
-from ui.topmenu import topmenu_items, the_user
-
from unfold.page import Page
-from plugins.myplugin import MyPlugin
-
# NOTE
# initially all the portal views were defined in this single file
# all the other ones have now migrated into separate classes/files for more convenience
@@ -46,17 +45,14 @@ class MyPluginView(FreeAccessView):
page = Page(self.request)
-# pres_view = PresView(page = page)
- plugin = MyPlugin(page = page, html="
PresView needs to be integrated
")
-
+ plugin = MyPlugin(page = page)
context = super(MyPluginView, self).get_context_data(**kwargs)
-
context['unfold_main'] = plugin.render(self.request)
# more general variables expected in the template
context['title'] = 'Sandbox for MyPlugin plugin'
# the menu items on the top
- context['topmenu_items'] = topmenu_items('PresView', self.request)
+ context['topmenu_items'] = topmenu_items_live('myplugin', page)
# so we can sho who is logged
context['username'] = the_user(self.request)
@@ -65,3 +61,35 @@ class MyPluginView(FreeAccessView):
return context
+
+class MadDashView(FreeAccessView):
+ template_name = "view-unfold1.html"
+
+ def get_context_data(self, **kwargs):
+ page = Page(self.request)
+
+ # This will simulate fake records in order to test the plugin
+ fake_query = Query.get('ping').select('hrn', 'src_hostname', 'dst_hostname', 'delay')
+ fake_query_all = Query.get('ping').select('hrn', 'src_hostname', 'dst_hostname', 'delay')
+
+ generators = {
+ 'hrn': 'random_string',
+ 'src_hostname': 'random_string',
+ 'dst_hostname': 'random_string',
+ 'delay': 'random_int'
+ }
+ page.generate_records(fake_query, generators, 5)
+ page.generate_records(fake_query_all, generators, 20)
+
+ plugin = MadDash(query = fake_query, query_all = fake_query_all, page = page)
+ context = super(MadDashView, self).get_context_data(**kwargs)
+ context['unfold_main'] = plugin.render(self.request)
+ context['title'] = 'Sandbox for MadDash plugin'
+ context['topmenu_items'] = topmenu_items_live ('maddash', page)
+ context['username'] = the_user(self.request)
+
+ prelude_env = page.prelude_env()
+ context.update(prelude_env)
+
+ return context
+