From: Yasin <mohammed-yasin.rahman@lip6.fr>
Date: Fri, 13 Dec 2013 17:19:25 +0000 (+0100)
Subject: All credentials visible
X-Git-Tag: myslice-0.3-0~89^2~1
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0bf98d7dbb4eeb8314ba315db529a83247bcc6ec;p=myslice.git

All credentials visible
---

diff --git a/portal/accountview.py b/portal/accountview.py
index 14a4435a..429b2d88 100644
--- a/portal/accountview.py
+++ b/portal/accountview.py
@@ -56,7 +56,9 @@ class AccountView(LoginRequiredAutoLogoutView):
         delegation_type_list = []
         exp_user_cred_list = []
         slice_list = []
+        auth_list = []
         slice_cred_exp_list = []
+        auth_cred_exp_list = []
         usr_hrn_list = []
         pub_key_list = []
           
@@ -72,8 +74,10 @@ class AccountView(LoginRequiredAutoLogoutView):
                     account_usr_hrn = account_config.get('user_hrn','N/A')
                     account_pub_key = account_config.get('user_public_key','N/A')
                     account_reference = account_config.get ('reference_platform','N/A')
-
+                    # credentials
                     acc_slice_cred = account_config.get('delegated_slice_credentials','N/A')
+                    acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+
                     if 'N/A' not in acc_slice_cred:
                         for key, value in acc_slice_cred.iteritems():
                             slice_list.append(key)
@@ -86,6 +90,19 @@ class AccountView(LoginRequiredAutoLogoutView):
                         my_slices = [{'slice_name': t[0], 'cred_exp': t[1]}
                             for t in zip(slice_list, slice_cred_exp_list)]
 
+                    if 'N/A' not in acc_auth_cred:
+                        for key, value in acc_auth_cred.iteritems():
+                            auth_list.append(key)
+                        #get cred_exp date
+                            exp_date = re.search('<expires>(.*)</expires>', value)
+                            if exp_date:
+                                exp_date = exp_date.group(1)
+                                auth_cred_exp_list.append(exp_date)
+
+                        my_auths = [{'auth_name': t[0], 'cred_exp': t[1]}
+                            for t in zip(auth_list, auth_cred_exp_list)]
+
+
                     account_user_credential = account_config.get('delegated_user_credential','N/A')
                     # Expiration date 
                     result = re.search('<expires>(.*)</expires>', account_user_credential)
@@ -139,6 +156,7 @@ class AccountView(LoginRequiredAutoLogoutView):
         context['ref_acc'] = secondary_list
         context['platform_list'] = platform_list
         context['my_slices'] = my_slices
+        context['my_auths'] = my_auths
         context['person']   = self.request.user
         context['firstname'] = config.get('firstname',"?")
         context['lastname'] = config.get('lastname',"?")
diff --git a/portal/templates/account-view.html b/portal/templates/account-view.html
index 30116df5..78e6b7f2 100644
--- a/portal/templates/account-view.html
+++ b/portal/templates/account-view.html
@@ -132,7 +132,7 @@
 </div>
 
 <h2>Account Information</h2>
-<h3>Principal Accounts</h3>
+<h3>Principal Account</h3>
 <div id="middle" align="center">
 	<div class="well">
 		<table class="mytable"> 
@@ -140,7 +140,6 @@
     			<th>Platform</th> 
         		<th>Account Type</th>
 				<th>Account_delegation</th>
-				<th>Credential Expiration</th> 	 
         		<th>user_hrn</th>
         		<!--<th>Pub Key</th> -->
     		</tr>   
@@ -149,7 +148,6 @@
     			<td class="odd"> {{ row.platform_name }} </td>
         		<td class="even"> {{ row.account_type }} </td>
 				<td class="odd"> {{ row.delegation_type }} </td>
-				<td class="even"> {{ row.credential_expiration }} </td>
        			<td class="odd"> {{ row.usr_hrn }}  </td>
         	<!--	<td class="even"> {{ row.usr_pubkey }} </td> -->
     		</tr> 
@@ -158,7 +156,59 @@
 	</div>
 </div>
 
-<h3>Secondary Accounts</h3>
+
+<h3>Credentials</h3>
+<div id="middle" align="center">
+    <div class="well">
+        <table class="mytable">
+			<caption><b>Delegated User Credential</b></caption> 
+            <tr class="odd"> 
+                <th>Expiration Date</th>
+            </tr>
+			{% for row in data %}         
+			<tr class="border_bottom">
+    			<td class="even"> {{ row.credential_expiration }} </td>
+			</tr>
+			{%endfor%}
+		 </table>
+		<p><button id="dl_user_cred" name= "dl_user_cred" type="submit" title="Download User Credential">Download</button></p>
+		 <table class="mytable">
+			<caption><b>Delegated Slice Credentials</b></caption>  
+     		<tr class="odd"> 
+				<th>Slice Name</th> 
+         		<th>Expiration Date</th>
+     		</tr>
+			{% for row in my_slices %}     
+     		<tr class="border_bottom">
+         		<td class="even"> {{ row.slice_name }} </td>
+				<td class="odd"> {{ row.cred_exp }} </td>
+     		</tr>
+     		{%endfor%}
+  		</table>
+		<p><button id="dl_slice_cred" name= "dl_slice_cred" type="submit" title="Download Slice Credentials">Download</button></p>
+		<table class="mytable">
+   			<caption><b>Delegated Authority Credentials</b></caption>
+   			<tr class="odd"> 
+       			<th>Authority Name</th> 
+       			<th>Expiration Date</th>
+   			</tr>
+   			{% for row in my_auths %}
+   			<tr class="border_bottom">
+       			<td class="even"> {{ row.auth_name }} </td>
+       			<td class="odd"> {{ row.cred_exp }} </td>
+   			</tr>
+   			{%endfor%}
+		</table>
+		<p><button id="dl_auth_cred" name= "dl_auth_cred" type="submit" title="Download Authority Credentials">Download</button></p>
+		<p></p>	
+		<p><button id="clear_cred" name= "clear_cred" type="submit" title="Clear All Credentials">Clear Credentials</button></p>
+    </div>
+</div>
+
+
+
+
+<h3>Testbed Accounts</h3>
 <div id="middle" align="center">
     <div class="well">
         <table class="mytable"> 
@@ -171,14 +221,14 @@
             <tr class="border_bottom">
                 <td class="odd"> {{ row.platform_name }} </td>
                 <td class="even"> {{ row.account_type }} </td>
-				<td class="even"> {{ row.account_reference }} </td>
+				<td class="odd"> {{ row.account_reference }} </td>
             </tr> 
             {%endfor%}               
         </table>
     </div>
 </div>
 
-<h2>Other Platforms</h2>
+<h3>Add Accounts</h3>
 <div id="middle" align="center">
     <div class="well">
         <table class="mytable"> 
@@ -190,7 +240,7 @@
             <tr class="border_bottom">
                 <td class="odd"> {{ platform.platform_no_access }} </td>
                 <td class="even">
-					<button id="request_access" name= {{platform.platform_no_access}} type="submit" title="Request Access to this platform">Request {{platform.platform_no_access}}</button>
+					<button id="request_access" name= {{platform.platform_no_access}} type="submit" title="Add account to this platform">Add {{platform.platform_no_access}}</button>
 				</td>
             </tr> 
             {%endfor%}               
@@ -198,32 +248,6 @@
     </div>
 </div>
 
-
-
-
-<h2>Slice Information</h2>
-<div id="middle" align="center">
-    <div class="well">
-        <table class="mytable"> 
-            <tr class="odd"> 
-                <th>Slice name</th> 
-                <th>Credential Expiration</th>
-            </tr>   
-            {% for row in my_slices %}         
-            <tr class="border_bottom">
-                <td class="odd"> {{ row.slice_name }} </td>
-                <td class="even"> {{ row.cred_exp }} </td>
-            </tr>
-            {%endfor%}
-        </table>
-    </div>
-</div>
-
-
-
-
 </form>
 
-
-
 {% endblock %}