MyAccount: Generate keys+Upload keys Ok [users needs to have account on myslice to...
authorYasin <mohammed-yasin.rahman@lip6.fr>
Wed, 18 Sep 2013 13:40:17 +0000 (15:40 +0200)
committerYasin <mohammed-yasin.rahman@lip6.fr>
Wed, 18 Sep 2013 13:40:17 +0000 (15:40 +0200)
portal/accountview.py
portal/actions.py
portal/static/css/account_view_html.css
portal/templates/account-view.html

index 5f7a396..5671b51 100644 (file)
@@ -2,13 +2,13 @@ from portal.templateviews            import LoginRequiredAutoLogoutView
 #
 from manifold.core.query             import Query
 from manifold.manifoldapi            import execute_query
-from portal.actions                  import manifold_update_user
+from portal.actions                  import manifold_update_user, manifold_update_account
 #
 from myslice.viewutils               import topmenu_items, the_user
 #
 from django.http                     import HttpResponse
 from django.contrib.auth.decorators  import login_required
-import json
+import json, os, re
 
 # requires login
 class AccountView(LoginRequiredAutoLogoutView):
@@ -132,14 +132,15 @@ def account_process(request):
         private_key = k.as_pem()
         private_key = ''.join(private_key.split())
         public_key = "ssh-rsa " + public_key
+        print "testing"
         # Saving to DB
         keypair = '{"user_public_key":"'+ public_key + '", "user_private_key":"'+ private_key + '"}'
 #        keypair = re.sub("\r", "", keypair)
 #        keypair = re.sub("\n", "\\n", keypair)
 #        #keypair = keypair.rstrip('\r\n')
 #        keypair = ''.join(keypair.split())
-        get_user.keypair = keypair
-        get_user.save()
+        user_params = { 'config': keypair}
+        manifold_update_account(request,user_params)
         return HttpResponse('Success: New Keypair Generated! %s' % keypair)
 
     elif 'upload_key' in request.POST:
@@ -150,11 +151,12 @@ def account_process(request):
         allowed_extension =  ['.pub','.txt']
         if file_extension in allowed_extension and re.search(r'ssh-rsa',file_content):
             file_content = '{"user_public_key":"'+ file_content +'"}'
-            file_content = re.sub("\r", "", file_content)
-            file_content = re.sub("\n", "\\n",file_content)
+            #file_content = re.sub("\r", "", file_content)
+            #file_content = re.sub("\n", "\\n",file_content)
             file_content = ''.join(file_content.split())
-            get_user.keypair = file_content
-            get_user.save()
+            # update manifold account table
+            user_params = { 'config': file_content}
+            manifold_update_account(request,user_params)
             return HttpResponse('Success: Publickey uploaded! Old records overwritten')
         else:
             return HttpResponse('Please upload a valid RSA public key [.txt or .pub].')    
index 03a0e93..21b2563 100644 (file)
@@ -72,7 +72,7 @@ def manifold_add_account(request, account_params):
 
 def manifold_update_account(request,account_params):
     # account_params: config
-    query = Query.update('local:account').filter_by('email', '==', request.user.email).set(account_params).select('email')
+    query = Query.update('local:account').filter_by('platform', '==', 'myslice').set(account_params).select('user_id')
     results = execute_query(request,query)
     # NOTE: results remains empty and goes to Exception. However, it updates the manifold DB.
     # That's why I commented the exception part. -- Yasin 
index 0b1b6bb..dd77998 100644 (file)
@@ -205,21 +205,11 @@ ul.errorlist li {
 
 
 
-table.mytable { border-collapse: collapse; border: 1px solid #839E99; 
-background: #f1f8ee; font: .9em/1.2em Georgia, "Times New Roman", Times, serif; color: #033;table-layout:fixed; }
-.mytable caption { font-size: 1.3em; font-weight: bold; text-align: left; padding: 1em 4px; }
+table.mytable { border-collapse: collapse; border: 1px solid #839E99;background: #f1f8ee; font: .9em/1.2em Georgia, "Times New Roman", Times, serif; color: #033;  table-layout:fixed; width:870px}
 .mytable td, th { padding: 3px 3px .75em 3px; line-height: 1.3em; }
-.mytable th { background: #839E99; color: #fff; font-weight: bold; text-align: left; padding-right: .5em; vertical-align: top; align="center" style="width:15%;word-wrap: break-word" }
-.mytable thead th { background: #2C5755; text-align: center; }
-.mytable thead td {style="width:15%;word-wrap: break-word"}
-.mytable .odd td { background: #DBE6DD; style="width:15%;word-wrap: break-word"}
-.mytable .odd th { background: #6E8D88; }
-.mytable td a, td a:link { color: #325C91; }
-.mytable td a:visited { color: #466C8E; }
-.mytable td a:hover, td a:focus { color: #1E4C94; }
-.mytable th a, td a:active { color: #fff; }
-.mytable tfoot th, tfoot td { background: #2C5755; color: #fff; }
-.mytable th + td { padding-left: .5em; }
+.mytable th { background: #839E99; color: #fff; font-weight: bold;  padding-right: .5em; vertical-align: top; text-align:center }
+.mytable  td {word-wrap: break-word; text-align:center}
+tr.border_bottom td {border-bottom:1pt solid green;}
 
 
 /******************************
index 8cd7c63..4e97f9d 100644 (file)
@@ -21,7 +21,7 @@
                        <th>Pub Key</th>
                </tr>   
                        {% for row in data %}         
-                       <tr class="even">
+                       <tr class="border_bottom">
                        <td class="odd"> {{ row.platform_name }} </td>
                        <td class="even"> {{ row.account_type }} </td>
                                <td class="odd"> {{ row.usr_hrn }}  </td>