From: Rezende & Pedro & Carlos & Raphael Date: Fri, 3 Oct 2014 20:10:32 +0000 (-0300) Subject: PI only sees slices/users of your own institution X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=e494918d8e6d9dab21b9ff30c3c2db2157dc0a20 PI only sees slices/users of your own institution columns inverted in the Mgt/User tab adding username in the resource tab --- diff --git a/portal/actions.py b/portal/actions.py index 285b4400..ccfa5e54 100644 --- a/portal/actions.py +++ b/portal/actions.py @@ -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: diff --git a/portal/sliceresourceview.py b/portal/sliceresourceview.py index e5614b04..1bdbc772 100644 --- a/portal/sliceresourceview.py +++ b/portal/sliceresourceview.py @@ -348,7 +348,8 @@ class SliceResourceView (LoginRequiredView, ThemeView): # template_env['pending_resources'] = pending_resources.render(self.request) template_env['sla_dialog'] = '' # sla_dialog.render(self.request) template_env["theme"] = self.theme - template_env["username"] = request.user + template_env["username"] = self.request.user + template_env["person"] = self.request.user template_env["pi"] = pi template_env["slice"] = slicename template_env["section"] = "resources" diff --git a/portal/templates/fibre/fibre__widget-topmenu.html b/portal/templates/fibre/fibre__widget-topmenu.html index a3ed9ff4..088ba069 100644 --- a/portal/templates/fibre/fibre__widget-topmenu.html +++ b/portal/templates/fibre/fibre__widget-topmenu.html @@ -37,7 +37,7 @@ {% if section != 'Registration' %} {% if username %} {% if person.username %} -
You are logged in as  {{ person.username }}   |   Logout
+
You are logged in as  {{ person.username }}   |   Logout
{% else %}
You are logged in as  {{ email }}   |   Logout
{% endif %} diff --git a/portal/templates/fibre/fibre_institution.html b/portal/templates/fibre/fibre_institution.html index 50cbd8c9..3ee7a553 100644 --- a/portal/templates/fibre/fibre_institution.html +++ b/portal/templates/fibre/fibre_institution.html @@ -38,8 +38,8 @@ + - @@ -98,10 +98,13 @@ $(document).ready(function() { {% if user_details.parent_authority %} $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) { + var username = "{{person.username}}"; var list_slices = []; var table_slices = []; /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */ $.each( data, function( key, val ) { + if(String(val.users).indexOf("@") != -1){ + if(String(val.users).split("@")[1] == username.split("@")[1]){ list_slices.push( "
  • " + val.slice_hrn + "
  • " ); if(val.nodes=="undefined" || val.nodes==null){ nodes_length=0; @@ -130,7 +133,8 @@ $(document).ready(function() { slice_row += ""; slice_row += ""; table_slices.push(slice_row); - + } + } }); /* $("div#slice-list").html($( ""; - user_row += ""; - user_row += ""; - user_row += ""; - user_row += ""; - user_row += ""; - user_row += ""; - user_row += ""; - table_users.push(user_row); + if (val.user_hrn.indexOf('@') != -1 ){ + if (val.user_hrn.split("@")[1] == username.split("@")[1]){ + list_users.push( "
  • " + val.user_email + "
  • " ); + user_row = ""; + user_row += ""; + user_row += ""; + user_row += ""; + user_row += ""; + user_row += ""; + user_row += ""; + user_row += ""; + table_users.push(user_row);} + } }); $("table#user-tab tr:last").after(table_users.join( "" )); $("div#user-tab-loaded").css("display","block");
    +/-User hrn EmailUser hrn First name Last name Enabled"+val.slice_expires+"
    "+val.user_email+""+val.user_hrn+""+val.user_first_name+""+val.user_last_name+""+val.user_enabled+"
    "+val.user_hrn+""+val.user_email+""+val.user_first_name+""+val.user_last_name+""+val.user_enabled+"