1 # this somehow is not used anymore - should it not be ?
2 from django.core.context_processors import csrf
3 from django.http import HttpResponseRedirect
4 from django.contrib.auth import authenticate, login, logout
5 from django.template import RequestContext
6 from django.shortcuts import render_to_response
7 from django.shortcuts import render
9 from unfold.loginrequired import FreeAccessView
11 from manifoldapi.manifoldresult import ManifoldResult
12 from manifold.core.query import Query
13 from manifoldapi.manifoldapi import execute_query
14 from ui.topmenu import topmenu_items, the_user
15 from myslice.configengine import ConfigEngine
17 from myslice.theme import ThemeView
19 class SupportView (FreeAccessView, ThemeView):
20 template_name = 'supportview.html'
24 def post (self,request):
26 env['theme'] = self.theme
27 return render_to_response(self.template, env, context_instance=RequestContext(request))
29 def get (self, request, state=None):
32 if request.user.is_authenticated():
33 env['person'] = self.request.user
34 ## check user is pi or not
35 platform_query = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
36 account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
37 platform_details = execute_query(self.request, platform_query)
38 account_details = execute_query(self.request, account_query)
39 for platform_detail in platform_details:
40 for account_detail in account_details:
41 if platform_detail['platform_id'] == account_detail['platform_id']:
42 if 'config' in account_detail and account_detail['config'] is not '':
43 account_config = json.loads(account_detail['config'])
44 if 'myslice' in platform_detail['platform']:
45 acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
47 if acc_auth_cred == {} or acc_auth_cred == 'N/A':
55 env['theme'] = self.theme
56 env['section'] = "Support"
58 env['username']=the_user(request)
60 if state: env['state'] = state
61 elif not env['username']: env['state'] = None
62 # use one or two columns for the layout - not logged in users will see the login prompt
64 return render_to_response(self.template, env, context_instance=RequestContext(request))