user_hrn = request['user_hrn'],
pi = request['pi'],
email_hash = request['email_hash'],
+ reasons = request['reasons'],
status = 'False',
)
b.save()
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
from myslice.theme import ThemeView
import json
+import ast
class ManagementRequestsView (LoginRequiredView, ThemeView):
template_name = "management-tab-requests.html"
ctx_delegation_authorities = {}
ctx_sub_authorities = {}
dest = {}
-
+ user_username = ''
+ user_authority = ''
# The user need to be logged in
if (self.request.user):
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
# 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
# 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
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())
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)
'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' : '',
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
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 = {}
<input id="authority_hrn" name="org_name" class="form-control" style="width:590px" value="{{ organization }}"
title="Choose your organization (company/university) from the list that apears when you click in the field and start to type.
Use the arrow keys to scroll through the list; type part of the name to narrow down the list. If it is not in the list,
- please request its addition by clicking the link below. We will send an email to the managers that we have on record for
+ please choose the FIBRE organization. We will send an email to the managers that we have on record for
your organization, asking them to validate your sign-up request." required />
<p></p>
- <p>Organization not listed? <a href="/portal/join">Request its addition now.</a></p>
+ <!-- <p>Organization not listed? <a href="/portal/join">Request its addition now.</a></p> -->
</div>
</div>
</div>
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 />
</div>
+ <div class="form-group">
+ <label for="Reasons" class="control-label" >Reasons for Applying</label>
+ <p></p>
+ <textarea type="text" rows="4" cols="70" name="reasons" size="25" class="form-control" style="width:350px;height:60px" minlength="5" maxlength="250" value="{{reasons}}" placeholder="Reasons for applying" title="Identify yourself and tell us more about your expectations to use the testbed." required ></textarea>
+ </div>
</div>
<div class="col-md-6">
<div class="col-md-12">
<div class="form-group" id="register">
<p></p>
- <input class="submit btn btn-onelab" type="submit" value="Sign up" />
+ <input class="submit btn btn-onelab" type="submit" value="Request My Account" />
</div>
</div>
</div>
<div class="row">
<h3>Sign up information received.</h3>
- <p>You can now log in to the portal. You will have limited access. </p>
- <p>To gain full access, two steps are required:</p>
+ <p>To gain full access, two steps are required:</p>
<ul>
<li>1. You confirm your signup request by clicking on the link in the email that we have sent to your email address.</li>
- <li>2. A manager from your organization validates your request. (We have sent email to your organisation's registered managers.)</li>
+ <li>2. A manager from the {{ REQINST }} will analize your request. (We have sent email to your organization's registered managers.)</li>
</ul>
<p></p>
<p></p>
<b>Public key :</b> {{public_key}}<br>
<b>Email :</b> {{email}}<br>
<b>User hrn :</b> {{user_hrn}}<br>
+<b>Reasons for applying :</b> {{ reasons }}<br>
<b>Portal url :</b> {{ current_site }}<br>
<p></p>
<p>You can validate the user <a href="https://{{current_site}}/portal/validate">here</a>.<p>
{% if my_authorities %}
{% for authority, requests in my_authorities.items %}
+ {% if authority == auth_hrn or "fibre" %}
+ <div class="col-md-12">
+ <h2>{{authority}}</h2>
+ </div>
- <div class="col-md-12">
- <h2>{{authority}}</h2>
- </div>
-
- <table class="table">
- <th>
- <td>Type</td>
- <td>Id</td>
- <td>Details</td>
- <td>Timestamp</td>
- <td>Status</td>
- </th>
- {% for request in requests %}
-
- <tr>
- <td>
- {% if request.allowed == 'allowed' %}
- <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
- {% else %}
- {% if request.allowed == 'expired' %}
- expired
- {% else %} {# denied #}
- denied
- {% endif %}
- {% endif %}
- </td>
- <td>{{ request.type }}</td>
- <td>{{ request.id }}</td>
- <td>
- {% 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 %}
- </td>
- <td>{{ request.timestamp }}</td>
-
- <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
-
- <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
- </tr>
-
- {% endfor %}
- </table>
- </div>
- {% endfor %}
-
-{% else %}
- <div class="col-md-12">
- <i>There is no pending request waiting for validation.</i>
- </div>
-{% endif %}
-<br />
-<div class="col-md-12">
- <h2>Sub-Authorities</h2>
-</div>
-{% if sub_authorities %}
-
- {% for authority, requests in sub_authorities.items %}
- <div class="col-md-12">
- <h3>{{authority}}</h3>
<table class="table">
<th>
<td>Type</td>
<td>Status</td>
</th>
{% for request in requests %}
+
<tr>
<td>
{% if request.allowed == 'allowed' %}
{% endif %}
</td>
<td>{{ request.timestamp }}</td>
-
+
<td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
-
- <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+
+ <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
</tr>
+
{% endfor %}
- </table>
- </div>
+ </table>
+ </div>
+ {% endif %}
{% endfor %}
+
{% else %}
-<div class="col-md-12">
- <i>There is no pending request waiting for validation.</i>
-</div>
+ <div class="col-md-12">
+ <i>There is no pending request waiting for validation.</i>
+ </div>
{% endif %}
<br />
<div class="col-md-12">
- <h2>Authorities with delegation</h2>
+ <h2>Sub-Authorities</h2>
</div>
-
-{% if delegation_authorities %}
+{% if sub_authorities %}
- {% for authority, requests in delegation_authorities.items %}
- <div class="col-md-12">
+ {% for authority, requests in sub_authorities.items %}
+ {% if authority == auth_hrn or "fibre" %}
+ <div class="col-md-12">
<h3>{{authority}}</h3>
<table class="table">
<th>
denied
{% endif %}
{% endif %}
- </td>
+ </td>
<td>{{ request.type }}</td>
<td>{{ request.id }}</td>
<td>
{% else %} {# authority #}
Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
{% endif %}
- {% endif %}
+ {% endif %}
</td>
<td>{{ request.timestamp }}</td>
<td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
- <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+ <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
</tr>
{% endfor %}
</table>
</div>
+ {% endif %}
+ {% endfor %}
+{% else %}
+<div class="col-md-12">
+ <i>There is no pending request waiting for validation.</i>
+</div>
+{% endif %}
+<br />
+<div class="col-md-12">
+ <h2>Authorities with delegation</h2>
+</div>
+
+{% if delegation_authorities %}
+
+ {% for authority, requests in delegation_authorities.items %}
+ <div class="col-md-12">
+ {% if authority == "fibre" or auth_hrn %}
+ <h3>{{authority}}</h3>
+ <table class="table">
+ <th>
+ <td>Type</td>
+ <td>Id</td>
+ <td>Details</td>
+ <td>Timestamp</td>
+ <td>Status</td>
+ </th>
+ {% for request in requests %}
+ <tr>
+ <td>
+ {% if request.allowed == 'allowed' %}
+ <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+ {% else %}
+ {% if request.allowed == 'expired' %}
+ expired
+ {% else %} {# denied #}
+ denied
+ {% endif %}
+ {% endif %}
+ </td>
+ <td>{{ request.type }}</td>
+ <td>{{ request.id }}</td>
+ <td>
+ {% 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 %}
+ </td>
+ <td>{{ request.timestamp }}</td>
+
+ <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
+
+ <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+ </tr>
+ {% endfor %}
+ </table>
+ {% endif %}
+ </div>
{% endfor %}
{% else %}
<div class="col-md-12">
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