Platform Access added to My Account. for loop in html table to be added
authorYasin <mohammed-yasin.rahman@lip6.fr>
Wed, 28 Aug 2013 16:32:05 +0000 (18:32 +0200)
committerYasin <mohammed-yasin.rahman@lip6.fr>
Wed, 28 Aug 2013 16:32:05 +0000 (18:32 +0200)
portal/templates/my_account.html
portal/views.py

index 2970c42..1500ce8 100644 (file)
@@ -3,6 +3,7 @@
 {% block head %}
 <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/my_account.common.css" />
 <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/my_account.profile.css" />
+<!-- <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/dashboard.css" /> !-->
 <script type="text/javascript" src="{{STATIC_URL}}/jquery.validate.js"></script> 
 <script type="text/javascript" src="{{STATIC_URL}}/my_account.edit_profile.js"></script>
 <script type="text/javascript" src="{{STATIC_URL}}/my_account.register.js"></script>
 {% block unfold1_main %}
 
 
+<h2>Platform Access</h2>
+<table border="2" bordercolor="FFCC00" style="table-layout:fixedbackground-color:FFFFCCwidth:830px" cellpadding="12" cellspacing="12"> 
+       <tr> 
+       <th align="center" style="width:15%">Platform</th> 
+        <th align="center" style="width:15%">Account Type</th> 
+        <th align="center" style="width:15%">user_hrn</th>
+        <th align="center">Pub Key</th>
+    </tr>            
+       <tr>
+       <td align="center"> {{ platform_name }} </td>
+        <td align="center"> {{ account_type }} </td>
+               <td align="center" style="word-wrap: break-word"> {{ account_usr_hrn }}  </td>
+        <td align="center" style="word-wrap: break-word"> {{ account_pub_key }} </td>
+    </tr>                
+</table>
+
+
+
 
 <div class='ms-dashboard-panel' id='ms-dashboard-slices' style=" display:block; float:none"  >
     <div class='ms-dashboard-caption'>
index d4fa22e..de7a5ac 100644 (file)
@@ -609,14 +609,41 @@ class AccountView(TemplateView):
     def get_context_data(self, **kwargs):
         #page = Page(self.request)
 
-        user_query  = Query().get('local:user').select('config')
-        user_accounts = execute_query(self.request, user_query)
+        user_query  = Query().get('local:user').select('config','email')
+        user_details = execute_query(self.request, user_query)
         
-        for user_account in user_accounts:
-            config = json.loads(user_account['config'])
-
-        #print "THis is a test"
-        #print config['firstname'] 
+        for user_detail in user_details:
+            #email = user_detail['email']
+            if user_detail['config']:
+                config = json.loads(user_detail['config'])
+
+        platform_query  = Query().get('local:platform').select('platform_id','platform')
+        account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
+        platform_details = execute_query(self.request, platform_query)
+        account_details = execute_query(self.request, account_query)
+       
+        # initial assignment needed for users having no account  
+        platform_name = ''
+        account_type = ''
+        account_usr_hrn = ''
+        account_pub_key = ''       
+        for account_detail in account_details:
+            for platform_detail in platform_details:
+                if platform_detail['platform_id'] == account_detail['platform_id']:
+                    platform_name = platform_detail['platform']
+                    account_type = account_detail['auth_type']
+                    account_config = json.loads(account_detail['config'])
+                    
+                    if 'user_hrn' in account_config:
+                        account_usr_hrn = account_config['user_hrn']
+                    else:
+                        account_usr_hrn = 'N/A'
+                    if 'user_public_key' in account_config:
+                        account_pub_key = account_config['user_public_key']
+                    else:
+                        account_pub_key = 'N/A'            
+                        #print "THis is a test"
+                        #print account_pub_key
         
         #page.enqueue_query(network_query)
 
@@ -631,6 +658,10 @@ class AccountView(TemplateView):
         #)
 
         context = super(AccountView, self).get_context_data(**kwargs)
+        context['platform_name'] = platform_name
+        context['account_type'] = account_type
+        context['account_usr_hrn'] = account_usr_hrn
+        context['account_pub_key'] = account_pub_key 
         context['person']   = self.request.user
         context ['fullname'] = config['firstname'] +' '+ config['lastname']    
         context ['firstname'] = config['firstname']