From: Rezende & Pedro & Carlos & Raphael Date: Mon, 1 Sep 2014 20:01:00 +0000 (-0300) Subject: - reasons for asking an account; rnp as a catch-all island; changing email messages... X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=87ecc18f2d0ac887d7fc278b7ba9efc27e0392af - reasons for asking an account; rnp as a catch-all island; changing email messages. etc. --- diff --git a/portal/actions.py b/portal/actions.py index dcf51bc0..93a32b91 100644 --- a/portal/actions.py +++ b/portal/actions.py @@ -754,6 +754,7 @@ def create_pending_user(wsgi_request, request, user_detail): user_hrn = request['user_hrn'], pi = request['pi'], email_hash = request['email_hash'], + reasons = request['reasons'], status = 'False', ) b.save() @@ -858,6 +859,7 @@ def create_pending_user(wsgi_request, request, user_detail): msg.attach_alternative(html_content, "text/html") msg.send() + print pi_emails except Exception, e: print "Failed to send email, please check the mail templates and the SMTP configuration of your server" import traceback diff --git a/portal/managementtabrequests.py b/portal/managementtabrequests.py index 85985a06..6e8a19d2 100644 --- a/portal/managementtabrequests.py +++ b/portal/managementtabrequests.py @@ -18,6 +18,7 @@ from portal.actions import get_requests from myslice.theme import ThemeView import json +import ast class ManagementRequestsView (LoginRequiredView, ThemeView): template_name = "management-tab-requests.html" @@ -28,7 +29,8 @@ class ManagementRequestsView (LoginRequiredView, ThemeView): ctx_delegation_authorities = {} ctx_sub_authorities = {} dest = {} - + user_username = '' + user_authority = '' # The user need to be logged in if (self.request.user): @@ -36,7 +38,12 @@ class ManagementRequestsView (LoginRequiredView, ThemeView): user_query = Query().get('local:user').filter_by('email', '==', self.request.user.username).select('user_id') user, = execute_query(self.request, user_query) user_id = user['user_id'] - + user_query = Query().get('local:user').filter_by('email', '==', self.request.user.username).select('config') + user, = execute_query(self.request, user_query) + user_config = user['config'] + user_config = ast.literal_eval(user_config) + user_authority = user_config['authority'] + user_username = self.request.user.username # Query manifold to learn about available SFA platforms for more information # In general we will at least have the portal # For now we are considering all registries @@ -120,8 +127,9 @@ class ManagementRequestsView (LoginRequiredView, ThemeView): # iterate on the requests and check if the authority matches a prefix # startswith an authority on which the user is PI requests = get_requests() - for r in requests: - auth_hrn = r['authority_hrn'] + auth_hrn = '' + for r in requests: + auth_hrn = r['authority_hrn'] for my_auth in pi_my_authorities: if auth_hrn.startswith(my_auth): dest = ctx_my_authorities @@ -156,10 +164,14 @@ class ManagementRequestsView (LoginRequiredView, ThemeView): # env['pi'] = "is_pi" # env['theme'] = self.theme # env['section'] = "Requests" - +# auth_hrn = user_authority + '.' + user_username.split("@")[1] + auth_hrn = user_username.split("@")[1] context = super(ManagementRequestsView, self).get_context_data(**kwargs) print "testing" print ctx_my_authorities + print auth_hrn + print user_username + print user_authority context['my_authorities'] = ctx_my_authorities context['sub_authorities'] = ctx_sub_authorities context['delegation_authorities'] = ctx_delegation_authorities @@ -174,6 +186,7 @@ class ManagementRequestsView (LoginRequiredView, ThemeView): context['pi'] = "is_pi" context['theme'] = self.theme context['section'] = "Requests" + context['auth_hrn'] = auth_hrn # XXX We need to prepare the page for queries #context.update(page.prelude_env()) diff --git a/portal/models.py b/portal/models.py index cc484b5b..acc336b4 100644 --- a/portal/models.py +++ b/portal/models.py @@ -66,7 +66,8 @@ class PendingUser(models.Model): login = models.TextField() pi = models.TextField() email_hash = models.TextField() - status = models.TextField() + status = models.TextField() + reasons = models.TextField() created = models.DateTimeField(auto_now_add = True) # models.ForeignKey(Institution) diff --git a/portal/registrationview.py b/portal/registrationview.py index 5da95598..4f0d6b87 100644 --- a/portal/registrationview.py +++ b/portal/registrationview.py @@ -83,6 +83,7 @@ class RegistrationView (FreeAccessView, ThemeView): 'email' : post_email, 'username' : wsgi_request.POST.get('username','').lower(), 'password' : wsgi_request.POST.get('password', ''), + 'reasons' : wsgi_request.POST.get('reasons', ''), 'current_site' : current_site, 'email_hash' : email_hash, 'pi' : '', @@ -98,7 +99,8 @@ class RegistrationView (FreeAccessView, ThemeView): username = user_request['username'] if user_request['authority_hrn'] == "fibre" : - user_request['username'] = user_request['username'] + "@" + "" # to be defined + user_request['username'] = user_request['username'] + "@" + "rnp" # catch-all island + split_authority = user_request['authority_hrn'] else : split_authority = user_request['authority_hrn'].split(".")[1] user_request['username'] = user_request['username'] + '@' + split_authority @@ -192,7 +194,7 @@ class RegistrationView (FreeAccessView, ThemeView): create_pending_user(wsgi_request, user_request, user_detail) self.template_name = 'user_register_complete.html' - return render(wsgi_request, self.template, {'theme': self.theme}) + return render(wsgi_request, self.template, {'theme': self.theme, 'REQINST':wsgi_request.POST.get('org_name', '').split(".")[1].upper()}) else: user_request = {} diff --git a/portal/templates/fibre/fibre_registration_view.html b/portal/templates/fibre/fibre_registration_view.html index a33338c3..b9236d6b 100644 --- a/portal/templates/fibre/fibre_registration_view.html +++ b/portal/templates/fibre/fibre_registration_view.html @@ -33,10 +33,10 @@

-

Organization not listed? Request its addition now.

+ @@ -57,6 +57,11 @@ title="Your e-mail address will be your identifier for logging in. We contact you to verify your account and then, occasionally, for important issues." placeholder="Email" required /> +
+ +

+ +
@@ -105,7 +110,7 @@

- +
diff --git a/portal/templates/fibre/fibre_user_register_complete.html b/portal/templates/fibre/fibre_user_register_complete.html index 4141c006..036262da 100644 --- a/portal/templates/fibre/fibre_user_register_complete.html +++ b/portal/templates/fibre/fibre_user_register_complete.html @@ -7,11 +7,10 @@

Sign up information received.

-

You can now log in to the portal. You will have limited access.

-

To gain full access, two steps are required:

+

To gain full access, two steps are required:

diff --git a/portal/templates/fibre/fibre_user_request_email.html b/portal/templates/fibre/fibre_user_request_email.html index 5a4c7eb5..8a6da3d5 100644 --- a/portal/templates/fibre/fibre_user_request_email.html +++ b/portal/templates/fibre/fibre_user_request_email.html @@ -12,6 +12,7 @@ Public key : {{public_key}}
Email : {{email}}
User hrn : {{user_hrn}}
+Reasons for applying : {{ reasons }}
Portal url : {{ current_site }}

You can validate the user here.

diff --git a/portal/templates/management-tab-requests.html b/portal/templates/management-tab-requests.html index d534915e..f148759c 100644 --- a/portal/templates/management-tab-requests.html +++ b/portal/templates/management-tab-requests.html @@ -49,72 +49,11 @@ {% if my_authorities %} {% for authority, requests in my_authorities.items %} + {% if authority == auth_hrn or "fibre" %} +

+

{{authority}}

+
-
-

{{authority}}

-
- - - - - - - - - {% for request in requests %} - - - - - - - - - - - - - - {% endfor %} -
- TypeIdDetailsTimestampStatus
- {% if request.allowed == 'allowed' %} - - {% else %} - {% if request.allowed == 'expired' %} - expired - {% else %} {# denied #} - denied - {% endif %} - {% endif %} - {{ request.type }}{{ request.id }} - {% if request.type == 'user' %} - Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}} - {% else %} - {% if request.type == 'slice' %} - Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}} - {% else %} {# authority #} - Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}} - {% endif %} - {% endif %} - {{ request.timestamp }}
-
- {% endfor %} - -{% else %} -
- There is no pending request waiting for validation. -
-{% endif %} -
-
-

Sub-Authorities

-
-{% if sub_authorities %} - - {% for authority, requests in sub_authorities.items %} -
-

{{authority}}

@@ -124,6 +63,7 @@ {% for request in requests %} + - + - - + + + {% endfor %} -
TypeStatus
{% if request.allowed == 'allowed' %} @@ -150,29 +90,32 @@ {% endif %} {{ request.timestamp }}
-
+ + + {% endif %} {% endfor %} + {% else %} -
- There is no pending request waiting for validation. -
+
+ There is no pending request waiting for validation. +
{% endif %}
-

Authorities with delegation

+

Sub-Authorities

- -{% if delegation_authorities %} +{% if sub_authorities %} - {% for authority, requests in delegation_authorities.items %} -
+ {% for authority, requests in sub_authorities.items %} + {% if authority == auth_hrn or "fibre" %} +

{{authority}}

- + {% endfor %}
@@ -194,7 +137,7 @@ denied {% endif %} {% endif %} - + {{ request.type }} {{ request.id }} @@ -206,17 +149,79 @@ {% else %} {# authority #} Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}} {% endif %} - {% endif %} + {% endif %} {{ request.timestamp }}
+ {% endif %} + {% endfor %} +{% else %} +
+ There is no pending request waiting for validation. +
+{% endif %} +
+
+

Authorities with delegation

+
+ +{% if delegation_authorities %} + + {% for authority, requests in delegation_authorities.items %} +
+ {% if authority == "fibre" or auth_hrn %} +

{{authority}}

+ + + + + + + + {% for request in requests %} + + + + + + + + + + + + {% endfor %} +
+ TypeIdDetailsTimestampStatus
+ {% if request.allowed == 'allowed' %} + + {% else %} + {% if request.allowed == 'expired' %} + expired + {% else %} {# denied #} + denied + {% endif %} + {% endif %} + {{ request.type }}{{ request.id }} + {% if request.type == 'user' %} + Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}} + {% else %} + {% if request.type == 'slice' %} + Slice name: {{request.slice_name}} -- user_hrn: {{ request.user_hrn }} -- Purpose: {{request.purpose}} + {% else %} {# authority #} + Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}} + {% endif %} + {% endif %} + {{ request.timestamp }}
+ {% endif %} +
{% endfor %} {% else %}
diff --git a/portal/validationview.py b/portal/validationview.py index b26ba0fa..10471308 100644 --- a/portal/validationview.py +++ b/portal/validationview.py @@ -262,6 +262,7 @@ class ValidatePendingView(LoginRequiredAutoLogoutView, ThemeView): context = super(ValidatePendingView, self).get_context_data(**kwargs) print "testing" print ctx_my_authorities + print auth_hrn context['my_authorities'] = ctx_my_authorities context['sub_authorities'] = ctx_sub_authorities context['delegation_authorities'] = ctx_delegation_authorities