From 45d2b44a9004321f02fa2ef3ab196bbb572b7123 Mon Sep 17 00:00:00 2001
From: Yasin <mohammed-yasin.rahman@lip6.fr>
Date: Tue, 24 Sep 2013 11:54:56 +0200
Subject: [PATCH] MyAccount: Delete key in progress

---
 portal/accountview.py | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/portal/accountview.py b/portal/accountview.py
index 71e68e68..b4b28a5e 100644
--- a/portal/accountview.py
+++ b/portal/accountview.py
@@ -196,7 +196,7 @@ def account_process(request):
                         return response
                         break
         else:
-            messages.success(request, 'Account error: You need an account in myslice platform to perform this action')
+            messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
             return HttpResponseRedirect("/portal/account/")
                
     elif 'dl_pkey' in request.POST:
@@ -205,19 +205,34 @@ def account_process(request):
                 if platform_detail['platform_id'] == account_detail['platform_id']:
                     if 'myslice' in platform_detail['platform']:
                         account_config = json.loads(account_detail['config'])
-                        print "hello"
                         if 'user_private_key' in account_config:
                             private_key = account_config['user_private_key']
                             response = HttpResponse(private_key, content_type='text/plain')
                             response['Content-Disposition'] = 'attachment; filename="privkey.txt"'
                             return response
                         else:
-                            messages.success(request, 'download error: Private key is not stored in the server')
+                            messages.error(request, 'Download error: Private key is not stored in the server')
                             return HttpResponseRedirect("/portal/account/")
 
         else:
-            messages.success(request, 'Account error: You need an account in myslice platform to perform this action')
+            messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
             return HttpResponseRedirect("/portal/account/")
+    
+    elif 'delete' in request.POST:
+        for account_detail in account_details:
+            for platform_detail in platform_details:
+                if platform_detail['platform_id'] == account_detail['platform_id']:
+                    if 'myslice' in platform_detail['platform']:
+                        account_config = json.loads(account_detail['config'])
+                        if 'user_private_key' in account_config:
+                            pass
+                        else:
+                            messages.error(request, 'Delete error: Private key is not stored in the server')
+                            return HttpResponseRedirect("/portal/account/")
+                           
+
+        #messages.success(request, 'delete key en cours')
+        #return HttpResponseRedirect("/portal/account/")
            
        
     else:
-- 
2.47.0