3 from manifold.core.query import Query
4 from manifoldapi.manifoldapi import execute_query
6 from unfold.page import Page
7 from unfold.loginrequired import FreeAccessView
8 from unfold.loginrequired import LoginRequiredAutoLogoutView
9 from ui.topmenu import topmenu_items_live, the_user
11 from plugins.lists.testbedlist import TestbedList
12 from plugins.lists.slicelist import SliceList
13 from plugins.querytable import QueryTable
14 from plugins.univbrisfoam import UnivbrisFoam
15 from plugins.univbrisfv import UnivbrisFv
16 from plugins.lists.staticlist import StaticList
17 from plugins.lists.slicelist import SliceList
18 from plugins.messages import Messages
19 from plugins.univbrisfvf import UnivbrisFvf
21 #This view requires login
22 class UnivbrisView (LoginRequiredAutoLogoutView):
23 #class UnivbrisView (FreeAccessView):
24 template_name = "univbris.html"
26 def get_context_data(self, **kwargs):
28 page = Page(self.request)
29 #print "UNIVBRIS page"
31 #create new query to manifold----query is not called yet
32 #need to modify to get i2cat of resources also
33 univbrisfoam_query=Query().get('ofelia-bristol-of:resource').select('urn')
36 page.enqueue_query(univbrisfoam_query)
37 page.expose_js_metadata()
39 #plugin which collects different openflow ports from maniford
40 univbrisfoamlist = UnivbrisFoam(
42 title = 'univbris_foam_ports_selection',
43 domid = 'univbris_foam_ports_selection',
44 query = univbrisfoam_query,
45 query_all = univbrisfoam_query,
47 datatables_options = {
49 'bLengthChange' : True,
54 #plugin which manages the different flowspaces that the user creates, and also sends flowspaces to manifold
55 univbrisfvlist = UnivbrisFv(
57 title = 'univbris_flowspace_selection',
58 domid = 'univbris_flowspace_selection',
61 datatables_options = {
63 'bLengthChange' : True,
68 #plugin which allows the definition of a single flowspace
69 univbrisfvform = UnivbrisFvf(
71 title = 'univbris_flowspace_form',
72 domid = 'univbris_flowspace_form',
75 datatables_options = {
77 'bLengthChange' : True,
82 #render plugins in each context within a single page, but not all plugins are visible at all time.
83 context = super(UnivbrisView, self).get_context_data(**kwargs)
84 context['person'] = self.request.user
85 context['resources'] = univbrisfoamlist.render(self.request)
86 context['flowspaces']= univbrisfvlist.render(self.request)
87 context['flowspaces_form']= univbrisfvform.render(self.request)
89 # XXX This is repeated in all pages
90 # more general variables expected in the template
91 context['title'] = 'Book OpenFlow resources'
92 # the menu items on the top
93 context['topmenu_items'] = topmenu_items_live('univbris', page)
94 # so we can sho who is logged
95 context['username'] = the_user(self.request)
97 context.update(page.prelude_env())
98 page.expose_js_metadata()
101 # the page header and other stuff
102 context.update(page.prelude_env())
104 context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"