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 myslice.viewutils 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 slice_query = Query().get('user').filter_by('user_hrn', '==', '$user_hrn').select('user_hrn', 'slice.slice_hrn')
26 auth_query = Query().get('network').select('network_hrn')
27 print "AUTH QUERY =====================", auth_query
28 print "filter", auth_query.filters
29 page.enqueue_query(slice_query)
30 page.enqueue_query(auth_query)
32 page.expose_js_metadata()
35 slicelist = SimpleList(
38 key = 'slice.slice_hrn',
42 authlist = SimpleList(
49 context = super(DashboardView, self).get_context_data(**kwargs)
50 context['person'] = self.request.user
51 context['networks'] = authlist.render(self.request)
52 context['slices'] = slicelist.render(self.request)
54 # XXX This is repeated in all pages
55 # more general variables expected in the template
56 context['title'] = 'Test view that combines various plugins'
57 # the menu items on the top
58 context['topmenu_items'] = topmenu_items('Dashboard', self.request)
59 # so we can sho who is logged
60 context['username'] = the_user(self.request)
62 context.update(page.prelude_env())