- Added support to send the user public key to the LaboraScheduler API on user regist...
[unfold.git] / portal / univbrisview.py
1 import json
2
3 from manifold.core.query        import Query
4 from manifoldapi.manifoldapi    import execute_query
5
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
10
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
20
21 #This view requires login 
22 class UnivbrisView (LoginRequiredAutoLogoutView):
23 #class UnivbrisView (FreeAccessView):
24     template_name = "univbris.html"
25     
26     def get_context_data(self, **kwargs):
27         
28         page = Page(self.request)
29         #print "UNIVBRIS page"
30         
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')
34             
35         #queue the query
36         page.enqueue_query(univbrisfoam_query)
37         page.expose_js_metadata()
38         
39         #plugin which collects different openflow ports from maniford
40         univbrisfoamlist = UnivbrisFoam(
41             page  = page,
42             title = 'univbris_foam_ports_selection',
43             domid = 'univbris_foam_ports_selection',
44             query = univbrisfoam_query,
45             query_all = univbrisfoam_query,
46             checkboxes = False,
47             datatables_options = { 
48                 'iDisplayLength': 10,
49                 'bLengthChange' : True,
50                 'bAutoWidth'    : True,
51                 },
52         )
53     
54         #plugin which manages the different flowspaces that the user creates, and also sends flowspaces to manifold
55         univbrisfvlist = UnivbrisFv(
56                 page  = page,
57                 title = 'univbris_flowspace_selection',
58                 domid = 'univbris_flowspace_selection',
59             query = None,
60                 query_all = None,
61                 datatables_options = { 
62                     'iDisplayLength': 5,
63                     'bLengthChange' : True,
64                     'bAutoWidth'    : True,
65                     },
66             )
67     
68         #plugin which allows the definition of a single flowspace
69         univbrisfvform = UnivbrisFvf(
70                 page  = page,
71                 title = 'univbris_flowspace_form',
72                 domid = 'univbris_flowspace_form',
73             query = None,
74                 query_all = None,
75                 datatables_options = { 
76                     'iDisplayLength': 3,
77                     'bLengthChange' : True,
78                     'bAutoWidth'    : True,
79                     },
80             )
81         
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)
88     
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)
96     
97         context.update(page.prelude_env())
98         page.expose_js_metadata()
99         
100     
101         # the page header and other stuff
102         context.update(page.prelude_env())
103     
104         context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"
105     
106         return context
107