7e7d53a42d9fefd352b88a5502d4e306a78581fd
[myslice.git] / portal / platformsview.py
1 from manifold.core.query         import Query
2 from unfold.page                 import Page
3
4 from unfold.loginrequired       import FreeAccessView
5 from ui.topmenu                  import topmenu_items_live, the_user
6
7 from plugins.querytable          import QueryTable
8
9 # View for platforms
10 class PlatformsView(FreeAccessView):
11     template_name = "platforms.html"
12
13     def get_context_data(self, **kwargs):
14         page = Page(self.request)
15         page.add_js_files  ( [ "js/common.functions.js" ] )
16         platform_query  = Query().get('local:platform').filter_by('disabled', '==', '0').select('platform','platform_longname','gateway_type')
17         #platform_query  = Query().get('local:platform').select('platform','platform_longname','gateway_type')
18         page.enqueue_query(platform_query)
19
20         page.expose_js_metadata()
21         platformlist = QueryTable(
22             page  = page,
23             title = 'List',
24             domid = 'checkboxes',
25             # this is the query at the core of the slice list
26             query = platform_query,
27             query_all = platform_query,
28             checkboxes = False,
29             datatables_options = { 
30                 'iDisplayLength': 10,
31                 'bLengthChange' : True,
32                 'bAutoWidth'    : True,
33                 },
34         )
35
36         context = super(PlatformsView, self).get_context_data(**kwargs)
37         context['person']   = self.request.user
38         context['platforms'] = platformlist.render(self.request)
39
40         # XXX This is repeated in all pages
41         # more general variables expected in the template
42         context['title'] = 'Platforms connected to MySlice'
43         # the menu items on the top
44         context['topmenu_items'] = topmenu_items_live('Platforms', page)
45         # so we can sho who is logged
46         context['username'] = the_user(self.request)
47
48         context.update(page.prelude_env())
49
50         context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"
51
52         return context