PI only sees slices/users of your own institution
[myslice.git] / portal / actions.py
index 24ad7f4..ccfa5e5 100644 (file)
@@ -469,6 +469,21 @@ def create_pending_slice(wsgi_request, request, email):
     try:
         # Send an email: the recipients are the PI of the authority
         recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
+       
+       pis = authority_get_pis(request, request['authority_hrn'])
+        pi_emails = []
+        for x in pis:
+            for e in x['pi_users']:
+                try:
+                    u = e.split(".")[1]
+                    y = User.objects.get(username = u)
+                   print y.username
+                    if y.username.count("@") != 0:
+                        if y.username.split("@")[1] == request['user_hrn'].split("@")[1]:
+                            pi_emails += [y.email]
+                           print y.email
+                except:
+                    print "fail"
 
         theme.template_name = 'slice_request_email.txt' 
         text_content = render_to_string(theme.template, request)
@@ -485,7 +500,7 @@ def create_pending_slice(wsgi_request, request, email):
         sender = sender.replace('\n', '')
 
         #sender = email
-        msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
+        msg = EmailMultiAlternatives(subject, text_content, sender, pi_emails)
         msg.attach_alternative(html_content, "text/html")
         msg.send()
     except Exception, e:
@@ -707,6 +722,16 @@ def create_user_in_ldap(wsgi_request, request, user_detail):
     # Add reference accounts for platforms
     manifold_add_reference_user_accounts(wsgi_request, request)
     
+    organization = request['username'].split('@')[1]
+    lsClient = LaboraSchedulerClient( organization )
+    
+    userId = lsClient.get_user_id_by_username( { 'username': str( request['username'] ) } )
+
+    ls_up_pkey = ls_update_public_key( wsgi_request, request, lsClient, userId )
+    
+    if ls_up_pkey:
+        print "OK PKEY"
+
     from sfa.util.xrn import Xrn 
 
     auth_pi = request.get('pi', None)