#
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):
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:
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].')
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
-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;}
/******************************