clean up the platforms view, rename network into platform
[myslice.git] / portal / platformsview.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 myslice.viewutils           import topmenu_items, the_user
7
8 from plugins.hazelnut            import Hazelnut
9
10 # View for platforms
11 class PlatformsView(TemplateView):
12     template_name = "platforms.html"
13
14     def get_context_data(self, **kwargs):
15         page = Page(self.request)
16
17         #platform_query  = Query().get('local:platform').filter_by('disabled', '==', '0').select('platform','platform_longname','gateway_type')
18         platform_query  = Query().get('local:platform').select('platform','platform_longname','gateway_type')
19         page.enqueue_query(platform_query)
20
21         page.expose_js_metadata()
22         page.expose_queries()
23         platformlist = Hazelnut(
24             page  = page,
25             title = 'List',
26             domid = 'checkboxes',
27             # this is the query at the core of the slice list
28             query = platform_query,
29             query_all = platform_query,
30             checkboxes = False,
31             datatables_options = {
32             # for now we turn off sorting on the checkboxes columns this way
33             # this of course should be automatic in hazelnut
34             'aoColumns'      : [None, None, None, None, {'bSortable': False}],
35             'iDisplayLength' : 25,
36             'bLengthChange'  : True,
37             },
38         )
39
40         context = super(PlatformsView, self).get_context_data(**kwargs)
41         context['person']   = self.request.user
42         context['platforms'] = platformlist.render(self.request)
43
44         # XXX This is repeated in all pages
45         # more general variables expected in the template
46         context['title'] = 'Platforms connected to MySlice'
47         # the menu items on the top
48         context['topmenu_items'] = topmenu_items('Platforms', self.request)
49         # so we can sho who is logged
50         context['username'] = the_user(self.request)
51
52         context.update(page.prelude_env())
53
54         return context