1 from django.template import RequestContext
2 from django.shortcuts import render_to_response
4 from manifold.core.query import Query, AnalyzedQuery
5 from manifoldapi.manifoldapi import execute_query
7 from django.views.generic.base import TemplateView
9 from unfold.loginrequired import LoginRequiredView
10 from django.http import HttpResponse
11 from django.shortcuts import render
13 from unfold.page import Page
14 from manifold.core.query import Query, AnalyzedQuery
15 from manifoldapi.manifoldapi import execute_query
17 from myslice.theme import ThemeView
20 class SliceUserView (LoginRequiredView, ThemeView):
21 template_name = "slice-tab-users-view.html"
23 def get(self, request, slicename):
24 if request.user.is_authenticated():
25 # user_query = Query().get('user').select('user_hrn','parent_authority').filter_by('user_hrn','==','$user_hrn')
26 #user_details = execute_query(self.request, user_query)
28 #if user_details[0]['parent_authority'] is None:
30 user_query = Query().get('local:user').select('config')
31 user_details = execute_query(request, user_query)
32 for user_config in user_details:
33 config = json.loads(user_config['config'])
34 config['authority'] = config.get('authority')
35 user_details[0]['parent_authority'] = config['authority']
37 return render_to_response(self.template, {"slice": slicename, "user_details":user_details[0], "theme": self.theme, "username": request.user, "section":"users"}, context_instance=RequestContext(request))