From: Loic Baron Date: Fri, 25 Jul 2014 18:31:07 +0000 (-0300) Subject: Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f96e36e0dbfab79de114bc7803066e0ffdf3876c;hp=-c;p=unfold.git Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre --- f96e36e0dbfab79de114bc7803066e0ffdf3876c diff --combined portal/actions.py index 5f173859,db6b649e..689e0f1d --- a/portal/actions.py +++ b/portal/actions.py @@@ -49,44 -49,6 +49,44 @@@ def authority_get_pi_emails(request, au results = execute_admin_query(request, query) return [result['user_email'] for result in results] +#clear user credentials +def clear_user_creds(request, user_email): + try: + user_query = Query().get('local:user').filter_by('email', '==', user_email).select('user_id','email','password','config') + user_details = execute_admin_query(request, user_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'] + + 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) + + 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']) + user_cred = account_config.get('delegated_user_credential','N/A') + if 'N/A' not in user_cred: + user_hrn = account_config.get('user_hrn','N/A') + user_pub_key = json.dumps(account_config.get('user_public_key','N/A')) + user_priv_key = json.dumps(account_config.get('user_private_key','N/A')) + updated_config = '{"user_public_key":'+ user_pub_key + ', "user_private_key":'+ user_priv_key + ', "user_hrn":"'+ user_hrn + '"}' + user_params = { 'config': updated_config} + manifold_update_account(request, user_id,user_params) + return user_email + else: + return None + + except Exception,e: + print "Exception in actions.py in clear_user_creds %s" % e + return None + def is_pi(wsgi_request, user_hrn, authority_hrn): # XXX could be done in a single query ! @@@ -153,6 -115,10 +153,10 @@@ def manifold_add_user(wsgi_request, req ? """ + + authority_hrn = request['authority_hrn'] + request['authority_hrn'] = authority_hrn.split(".")[0] + USER_CONFIG = '{"firstname": "%(first_name)s", "lastname": "%(last_name)s", "authority": "%(authority_hrn)s"}' user_params = { @@@ -162,6 -128,8 +166,8 @@@ 'status' : 1, } + request['authority_hrn'] = authority_hrn + query = Query.create('local:user').set(user_params).select('email') results = execute_admin_query(request, query) if not results: @@@ -473,7 -441,11 +479,11 @@@ def create_pending_slice(wsgi_request, subject = render_to_string(theme.template, request) subject = subject.replace('\n', '') - sender = email + theme.template_name = 'email_default_sender.txt' + sender = render_to_string(theme.template, request) + sender = sender.replace('\n', '') + + #sender = email msg = EmailMultiAlternatives(subject, text_content, sender, recipients) msg.attach_alternative(html_content, "text/html") msg.send() @@@ -560,7 -532,7 +570,7 @@@ def sfa_create_user(wsgi_request, reque else: subject = 'User validated' msg = 'A manager of your institution has validated your account. You have now full user access to the portal.' - send_mail(subject, msg, 'support@onelab.eu',[request['email']], fail_silently=False) + send_mail(subject, msg, 'support@fibre.org.br',[request['email']], fail_silently=False) return results def ldap_create_user(wsgi_request, request, user_detail): @@@ -819,7 -791,10 +829,10 @@@ def create_pending_user(wsgi_request, r try: # Send an email: the recipients are the PI of the authority # If No PI is defined for this Authority, send to a default email (different for each theme) - recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn']) + + split_authority_hrn = request['authority_hrn'].split(".")[0] + + recipients = authority_get_pi_emails(wsgi_request, split_authority_hrn) theme.template_name = 'user_request_email.html' html_content = render_to_string(theme.template, request)