X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=blobdiff_plain;f=portal%2Fmanageuserview.py;h=5c9ad23d4793ca077f83182d4b0660ca64fc41ef;hp=391e72c1dadee1e034a7aeebdb47d860b55f5846;hb=74559bc02e54d941489bc789f9337cd9ef7187d7;hpb=350a118a4f8e3329f39fe7f245cb27388a3756f0 diff --git a/portal/manageuserview.py b/portal/manageuserview.py index 391e72c1..5c9ad23d 100644 --- a/portal/manageuserview.py +++ b/portal/manageuserview.py @@ -41,8 +41,6 @@ class UserView(LoginRequiredAutoLogoutView): for user_detail in user_details: user_id = user_detail['user_id'] user_email = user_detail['email'] - print "hello_world" - print user_id # different significations of user_status if user_detail['status'] == 0: user_status = 'Disabled' @@ -221,8 +219,8 @@ def user_process(request, **kwargs): for key, value in kwargs.iteritems(): if key == "email": selected_email=value - print "yasin" - print selected_email + + redirect_url = "/portal/user/"+selected_email user_query = Query().get('local:user').filter_by('email', '==', selected_email).select('user_id','email','password','config') user_details = execute_admin_query(request, user_query) @@ -230,19 +228,14 @@ def user_process(request, **kwargs): # getting the user_id from the session for user_detail in user_details: user_id = user_detail['user_id'] - + user_email = user_detail['email'] + account_query = Query().get('local:account').filter_by('user_id', '==', user_id).select('user_id','platform_id','auth_type','config') account_details = execute_admin_query(request, account_query) platform_query = Query().get('local:platform').select('platform_id','platform') platform_details = execute_admin_query(request, platform_query) - # getting the user_id from the session - for user_detail in user_details: - user_id = user_detail['user_id'] - user_email = user_detail['email'] - - redirect_url = "/portal/user/"+selected_email for account_detail in account_details: for platform_detail in platform_details: @@ -326,17 +319,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 @@ -360,9 +363,9 @@ def user_process(request, **kwargs): user_params = { 'config': keypair, 'auth_type':'managed'} manifold_update_account(request,user_params) # updating sfa - public_key = public_key.replace('"', ''); - user_pub_key = {'keys': public_key} - sfa_update_user(request, user_hrn, user_pub_key) + #public_key = public_key.replace('"', ''); + #user_pub_key = {'keys': public_key} + #sfa_update_user(request, user_hrn, user_pub_key) messages.success(request, 'Sucess: New Keypair Generated! Delegation of your credentials will be automatic.') return HttpResponseRedirect(redirect_url) else: