1 from manifold.core.query import Query
2 from unfold.page import Page
4 from plugins.lists.simplelist import SimpleList
6 from unfold.loginrequired import LoginRequiredAutoLogoutView
8 from ui.topmenu import topmenu_items, the_user
10 #This view requires login
11 class DashboardView (LoginRequiredAutoLogoutView):
13 template_name = "dashboard.html"
15 def get_context_data(self, **kwargs):
16 # We might have slices on different registries with different user accounts
17 # We note that this portal could be specific to a given registry, to which we register users, but i'm not sure that simplifies things
18 # Different registries mean different identities, unless we identify via SFA HRN or have associated the user email to a single hrn
20 #messages.info(self.request, 'You have logged in')
21 page = Page(self.request)
24 #slice_query = Query().get('slice').filter_by('user.user_hrn', 'contains', user_hrn).select('slice_hrn')
25 auth_query = Query().get('network').select('network_hrn','platform')
26 # DEMO GEC18 Query only PLE
27 slice_query = Query().get('user').filter_by('user_hrn', '==', '$user_hrn').select('user_hrn', 'slice.slice_hrn')
28 page.enqueue_query(slice_query)
29 page.enqueue_query(auth_query)
31 page.expose_js_metadata()
34 slicelist = SimpleList(
37 key = 'slice.slice_hrn',
40 # XXX TODO: plugins/lists/static/js/simplelist.js => hardcoded keys that give links : slice_hrn & platform
41 authlist = SimpleList(
48 context = super(DashboardView, self).get_context_data(**kwargs)
49 context['person'] = self.request.user
50 context['networks'] = authlist.render(self.request)
51 context['slices'] = slicelist.render(self.request)
53 # XXX This is repeated in all pages
54 # more general variables expected in the template
55 context['title'] = 'Dashboard'
56 # the menu items on the top
57 context['topmenu_items'] = topmenu_items('Dashboard', self.request)
58 # so we can sho who is logged
59 context['username'] = the_user(self.request)
61 context.update(page.prelude_env())