myslice.ini possible themes = onelab, fed4fire, fibre, smartfire
[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             init_key   = 'platform',
30             datatables_options = { 
31                 'iDisplayLength': 10,
32                 'bLengthChange' : True,
33                 'bAutoWidth'    : True,
34                 },
35         )
36
37         context = super(PlatformsView, self).get_context_data(**kwargs)
38         context['person']   = self.request.user
39         context['platforms'] = platformlist.render(self.request)
40
41         # XXX This is repeated in all pages
42         # more general variables expected in the template
43         context['title'] = 'Platforms connected to MySlice'
44         # the menu items on the top
45         context['topmenu_items'] = topmenu_items_live('Platforms', page)
46         # so we can sho who is logged
47         context['username'] = the_user(self.request)
48
49         context.update(page.prelude_env())
50
51         context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"
52
53         return context