Merge branch 'master' of ssh://git.onelab.eu/git/myslice
[myslice.git] / portal / platformview.py
1 from django.views.generic.base   import TemplateView
2
3 from manifold.core.query         import Query
4 from unfold.page                 import Page
5
6 from ui.topmenu                  import topmenu_items, the_user
7
8 from plugins.hazelnut            import Hazelnut
9
10 # View for 1 platform and its details
11 class PlatformView(TemplateView):
12     template_name = "platform.html"
13
14     def get_context_data(self, **kwargs):
15         page = Page(self.request)
16
17         for key, value in kwargs.iteritems():
18             print "%s = %s" % (key, value)       
19             if key == "platformname":
20                 platformname=value
21                 
22         network_query  = Query().get('local:platform')\
23             .filter_by('platform', '==', platformname)\
24             .select('platform','platform_longname','gateway_type')
25         page.enqueue_query(network_query)
26
27         page.expose_js_metadata()
28         page.expose_queries()
29         networklist = Hazelnut(
30             page  = page,
31             title = 'List',
32             domid = 'checkboxes',
33             # this is the query at the core of the slice list
34             query = network_query,
35             query_all = network_query,
36             checkboxes = False,
37             datatables_options = {
38             # for now we turn off sorting on the checkboxes columns this way
39             # this of course should be automatic in hazelnut
40             'aoColumns'      : [None, None, None, None, {'bSortable': False}],
41             'iDisplayLength' : 25,
42             'bLengthChange'  : True,
43             },
44         )
45 #
46 #        networklist = SimpleList(
47 #            title = None,
48 #            page  = page,
49 #            key   = 'platform',
50 #            query = network_query,
51 #        )
52
53         context = super(PlatformView, self).get_context_data(**kwargs)
54         context['person']   = self.request.user
55         context['networks'] = networklist.render(self.request)
56
57         # XXX This is repeated in all pages
58         # more general variables expected in the template
59         context['title'] = 'Platforms connected to MySlice'
60         # the menu items on the top
61         context['topmenu_items'] = topmenu_items('Platforms', self.request)
62         # so we can sho who is logged
63         context['username'] = the_user(self.request)
64
65         context.update(page.prelude_env())
66
67         return context
68
69
70