Import error for Log
[unfold.git] / portal / slicetabusers.py
1 from django.template                 import RequestContext
2 from django.shortcuts                import render_to_response
3
4 from manifold.core.query             import Query, AnalyzedQuery
5 from manifoldapi.manifoldapi         import execute_query
6
7 from django.views.generic.base      import TemplateView
8
9 from unfold.loginrequired           import LoginRequiredView
10 from django.http import HttpResponse
11 from django.shortcuts import render
12
13 from unfold.page                     import Page
14 from manifold.core.query             import Query, AnalyzedQuery
15 from manifoldapi.manifoldapi         import execute_query
16
17 from myslice.theme import ThemeView
18 import json
19
20 class SliceUserView (LoginRequiredView, ThemeView):
21     template_name = "slice-tab-users-view.html"
22     
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)
27             # if sfa returns None
28             #if user_details[0]['parent_authority'] is None:
29                 # find in local DB 
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']
36
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))