From: Yasin <mohammed-yasin.rahman@lip6.fr>
Date: Mon, 17 Feb 2014 15:38:39 +0000 (+0100)
Subject: ManageUser: email edit disabled [will be too complicated(user_hrn??).]. Authority... 
X-Git-Tag: myslice-1.1~331^2~8
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=d25b15bb54f4d6b26664d7c2554f632d767e461b;p=myslice.git

ManageUser: email edit disabled [will be too complicated(user_hrn??).]. Authority edit enabled
---

diff --git a/portal/manageuserview.py b/portal/manageuserview.py
index 11166bbe..3f3ebde6 100644
--- a/portal/manageuserview.py
+++ b/portal/manageuserview.py
@@ -321,17 +321,27 @@ def user_process(request, **kwargs):
         messages.success(request, 'Sucess: First Name and Last Name Updated.')
         return HttpResponseRedirect(redirect_url)       
     
-    #elif 'submit_pass' in request.POST:
-    #    edited_password = request.POST['password']
-    #    
-    #    for user_pass in user_details:
-    #        user_pass['password'] = edited_password
-    #    #updating password in local:user
-    #    user_params = { 'password': user_pass['password']}
-    #    manifold_update_user(request,request.user.email,user_params)
-#   #     return HttpResponse('Success: Password Changed!!')
-    #    messages.success(request, 'Sucess: Password Updated.')
-    #    return HttpResponseRedirect("/portal/account/")
+    elif 'submit_auth' in request.POST:
+        edited_auth = request.POST['authority']
+        
+        config={}
+        for user_config in user_details:
+            if user_config['config']:
+                config = json.loads(user_config['config'])
+                config['firstname'] = config.get('firstname', 'N/A')
+                config['lastname'] = config.get('lastname','N/A')
+                config['authority'] = edited_auth
+                updated_config = json.dumps(config)
+                user_params = {'config': updated_config}
+            else: # it's needed if the config is empty 
+                user_config['config']= '{"firstname": "N/A", "lastname":"N/A", "authority":"' + edited_auth + '"}'
+                user_params = {'config': user_config['config']}
+        # updating config local:user in manifold       
+        manifold_update_user(request, user_email, user_params)
+        # this will be depricated, we will show the success msg in same page
+        # Redirect to same page with success message
+        messages.success(request, 'Sucess: Authority Updated.')
+        return HttpResponseRedirect(redirect_url)
 
 # XXX TODO: Factorize with portal/registrationview.py
 
diff --git a/portal/templates/manageuserview.html b/portal/templates/manageuserview.html
index 9b45708e..3675c9af 100644
--- a/portal/templates/manageuserview.html
+++ b/portal/templates/manageuserview.html
@@ -22,22 +22,11 @@
 						<div id="info">Platform: Myslice</div>
 	      			</td>
 	    		</tr>
-				<tr class="odd">
+				<tr class="even">
     				<td class="key">Email</td>
-    				<td class="value">
-        				<span id="emailval" class="value" >{{ user_email }} </span>
-        				<span class="hide_this" id="span_email">
-            				<button type="button" class="btn btn-default btn-xs" title="Cancel" id="cancel_email_change"> Cancel </button>
-            				<div style='display:none;'><input type='hidden'  name='emailform'  /></div>
-            				<input id="email" type="text" name="email" class="required"  maxlength="200" value="{{user_email}}" />
-            				<input type="submit" class="btn btn-default btn-xs" name="submit_email" value="Save"/>
-        				</span>
-        				<button class="btn btn-default btn-xs" type="button"title="email" id="edit_email">
-            				<span class="glyphicon glyphicon-edit"></span> Edit
-        				</button>
-    				</td>
-				</tr>       
-	      		<tr class="even">
+    				<td class="value"> <span id="emailval" class="value" >{{ user_email }}</span> </td>
+				</tr>
+	      		<tr class="odd">
 					<td class="key">Full Name</td>
 					<td class="value">
 		  				<span id="nameval" class="value" >{{ fullname }} </span>
@@ -53,7 +42,7 @@
 						</button>
 					</td>
 	      		</tr>
-				<tr class="odd">
+				<tr class="even">
      				<td class="key">Authority</td>
      				<td class="value">
          				<span id="authval" class="value" >{{ authority }} </span>
@@ -68,7 +57,7 @@
         	 			</button>
      				</td>
  				</tr>     
-				<tr class="even">
+				<tr class="odd">
 		  			<td class="key">Generate Keys</td>
 		  			<td>
 						<input type="submit" name="generate" class="btn btn-danger btn-xs" value="Generate a new Key Pair" id="generate_keypair" 
@@ -76,7 +65,7 @@
 							   title="It will generate a new key Pair and your current credentials will be overwritten."/>
 	      			</td> 
 	    		</tr>
-	    		<tr class="odd">
+	    		<tr class="even">
 	      			<td class="key">Public Key</td>
 	      			<td class="value">
 						<span id="keyval" class="value">******** </span>
@@ -97,7 +86,7 @@
 						</button>       
 	      			</td>
 	    		</tr>
-	    		<tr class="even" id="pkey_row">
+	    		<tr class="odd" id="pkey_row">
 				 {%if 'N/A' not in user_private_key%}
 	      			<td class="key">Private Key </td> <!-- Hide if priv_key doesn't exist in myslice platform   -->
 	      			<td class="value">********<a href="#">