request_status['SFA user'] = {'status': True }
# getting user email based on id
## RAW SQL queries on Django DB- https://docs.djangoproject.com/en/dev/topics/db/sql/
- for user in PendingUser.objects.raw('SELECT id,email FROM portal_pendinguser WHERE id = %s', [request['id']]):
+ for user in PendingUser.objects.raw('SELECT * FROM portal_pendinguser WHERE id = %s', [request['id']]):
user_email= user.email
+ first_name = user.first_name
+ last_name = user.last_name
# get the domain url
current_site = Site.objects.get_current()
current_site = current_site.domain
- subject = 'User validation denied.'
- msg = 'You have recently registered to ' + current_site + '. We are sorry to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.'
- send_mail(subject, msg, 'support@onelab.eu',[user_email], fail_silently=False)
+ ctx = {
+ 'first_name' : first_name,
+ 'last_name' : last_name,
+ 'portal_url' : current_site,
+ }
+ try:
+ theme.template_name = 'user_request_denied.txt'
+ text_content = render_to_string(theme.template, ctx)
+ theme.template_name = 'user_request_denied.html'
+ html_content = render_to_string(theme.template, ctx)
+ theme.template_name = 'email_default_sender.txt'
+ sender = render_to_string(theme.template, ctx)
+ sender = sender.replace('\n', '')
+
+ subject = 'User validation denied.'
+
+ msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
+ msg.attach_alternative(html_content, "text/html")
+ msg.send()
+ except Exception, e:
+ print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+
# removing from Django auth_user
UserModel = get_user_model()
UserModel._default_manager.filter(email__iexact = user_email).delete()
request_status['SFA authority'] = {'status': False, 'description': str(e)}
elif request['type'] == 'slice':
- request_status['SFA slice'] = {'status': True }
+ request_status['SFA slice'] = {'status': True }
+
+ # getting user email based on id
+ ## RAW SQL queries on Django DB- https://docs.djangoproject.com/en/dev/topics/db/sql/
+ for user in PendingUser.objects.raw('SELECT * FROM portal_pendingslice WHERE id = %s', [request['id']]):
+ user_email= user.type_of_nodes # XXX type_of_nodes field contains the email [shd be renamed]
+
+ # get the domain url
+ current_site = Site.objects.get_current()
+ current_site = current_site.domain
+
+ ctx = {
+ 'portal_url' : current_site,
+ }
+ try:
+ theme.template_name = 'slice_request_denied.txt'
+ text_content = render_to_string(theme.template, ctx)
+ theme.template_name = 'slice_request_denied.html'
+ html_content = render_to_string(theme.template, ctx)
+ theme.template_name = 'email_default_sender.txt'
+ sender = render_to_string(theme.template, ctx)
+ sender = sender.replace('\n', '')
+
+ subject = 'Slice request denied.'
+
+ msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
+ msg.attach_alternative(html_content, "text/html")
+ msg.send()
+ except Exception, e:
+ print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+
PendingSlice.objects.get(id=request['id']).delete()
elif request['type'] == 'authority':
request_status['SFA authority'] = {'status': True }
raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn']
else:
clear_user_creds(wsgi_request,user_email)
- subject = 'Slice created'
- msg = 'A manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.'
- send_mail(subject, msg, 'support@onelab.eu',[user_email], fail_silently=False)
+
+ try:
+ theme.template_name = 'slice_request_validated.txt'
+ text_content = render_to_string(theme.template, request)
+ theme.template_name = 'slice_request_validated.html'
+ html_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'email_default_sender.txt'
+ sender = render_to_string(theme.template, request)
+ sender = sender.replace('\n', '')
+
+ subject = 'Slice request validated'
+
+ msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
+ msg.attach_alternative(html_content, "text/html")
+ msg.send()
+ except Exception, e:
+ print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
return results
slice_name = request['slice_name'],
user_hrn = request['user_hrn'],
authority_hrn = request['authority_hrn'],
- number_of_nodes = request['url'],
+ number_of_nodes = request['url'], # field needs to be renamed
purpose = request['purpose'],
+ type_of_nodes = request['email'] # field needs to be renamed
)
s.save()
if not results:
raise Exception, "Could not create %s. Already exists ?" % sfa_user_params['user_hrn']
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)
+ try:
+ theme.template_name = 'user_request_validated.txt'
+ text_content = render_to_string(theme.template, request)
+ theme.template_name = 'user_request_validated.html'
+ html_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'email_default_sender.txt'
+ sender = render_to_string(theme.template, request)
+ sender = sender.replace('\n', '')
+
+
+ subject = 'User validated'
+
+ msg = EmailMultiAlternatives(subject, text_content, sender, [request['email']])
+ msg.attach_alternative(html_content, "text/html")
+ msg.send()
+ except Exception, e:
+ print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+
return results
def create_user(wsgi_request, request, namespace = None, as_admin = False):
site_url = reg_site_url,
site_latitude = reg_site_latitude,
site_longitude = reg_site_longitude,
- address_line1 = reg_address_line1,
+ address_line1 = reg_email, # XXX field name must be renamed. Email needed 4 rejection email.
address_line2 = reg_address_line2,
address_line3 = reg_address_line3,
address_city = reg_address_city,
'authority_hrn' : reg_root_authority_hrn + '.' + reg_site_authority,
'site_abbreviated_name' : reg_site_abbreviated_name,
'site_url' : reg_site_url,
- 'site_latitude' : reg_site_latitude,
- 'site_longitude' : reg_site_longitude,
- 'address_line1' : reg_address_line1,
- 'address_line2' : reg_address_line2,
- 'address_line3' : reg_address_line3,
'address_city' : reg_address_city,
- 'address_postalcode' : reg_address_postalcode,
- 'address_state' : reg_address_state,
'address_country' : reg_address_country,
'first_name' : reg_fname,
'last_name' : reg_lname,
'user_hrn' : user_hrn,
'public_key' : public_key,
}
- recipients = authority_get_pi_emails(request,reg_auth)
+
+ #recipients = authority_get_pi_emails(request,reg_auth)
- # We don't need to send this email to user.
- # it's for the PI only
- #if ctx['cc_myself']:
- # recipients.append(ctx['email'])
- theme.template_name = 'authority_request_email.html'
- html_content = render_to_string(theme.template, ctx)
+ self.template_name = 'authority_request_email.html'
+ html_content = render_to_string(self.template, ctx)
- theme.template_name = 'authority_request_email.txt'
- text_content = render_to_string(theme.template, ctx)
+ self.template_name = 'authority_request_email.txt'
+ text_content = render_to_string(self.template, ctx)
- theme.template_name = 'authority_request_email_subject.txt'
- subject = render_to_string(theme.template, ctx)
+ self.template_name = 'authority_request_email_subject.txt'
+ subject = render_to_string(self.template, ctx)
subject = subject.replace('\n', '')
- theme.template_name = 'email_default_sender.txt'
- sender = render_to_string(theme.template, ctx)
- sender = sender.replace('\n', '')
-
- msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
+ #theme.template_name = 'email_default_sender.txt'
+ #sender = render_to_string(theme.template, ctx)
+ #sender = sender.replace('\n', '')
+ sender = reg_email
+
+ msg = EmailMultiAlternatives(subject, text_content, sender, ['support@onelab.eu'])
msg.attach_alternative(html_content, "text/html")
msg.send()
except Exception, e:
print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
-
+ import traceback
+ traceback.print_exc()
+
self.template_name = 'join_complete.html'
# log institution activity
activity.institution.joined(self.request)
-<img src="https://onelab.eu/templates/onelab2/images/logo.png">
+<img src="{{ STATIC_URL }}img/onelab.png">
<br>
<h1>NEW AUTHORITY REQUEST</h1>
<br>
+<p>This email is only for OneLab admins</p>
+<br>
<h2>{{site_name}}</h2>
-<b>Authority hrn :</b> {{authority_hrn}}
-<b>Abreviated name :</b> {{site_abbreviated_name}}
-<b>URL :</b> {{site_url}}
-<b>latitude :</b> {{site_latitude}}
-<b>longitude :</b> {{site_longitude}}
-<b>Address :</b> {{address_line1}}<br>
- {{address_line2}}<br>
- {{address_line3}}<br>
-<b>City :</b> {{address_city}}
-<b>Postcode :</b> {{address_postalcode}}
-<b>State :</b> {{address_state}}
-<b>Country :</b> {{address_country}}
+<b>Authority hrn :</b> {{authority_hrn}}<br>
+<b>Abreviated name :</b> {{site_abbreviated_name}}<br>
+<b>URL :</b> {{site_url}}<br>
+<b>City :</b> {{address_city}}<br>
+<b>Postcode :</b> {{address_postalcode}}<br>
+<b>State :</b> {{address_state}}<br>
+<b>Country :</b> {{address_country}}<br>
<br><br>
<h2>PI for this Authority</h2>
-<b>First Name :</b> {{first_name}}
-<b>Last Name :</b> {{last_name}}
-<b>Authority hrn:</b> {{authority_hrn}}
-<b>Public key :</b> {{public_key}}
-<b>Email :</b> {{email}}
-<b>User Hrn :</b> {{user_hrn}}
+<b>First Name :</b> {{first_name}}<br>
+<b>Last Name :</b> {{last_name}}<br>
+<b>Authority hrn:</b> {{authority_hrn}}<br>
+<b>Public key :</b> {{public_key}}<br>
+<b>Email :</b> {{email}}<br>
+<b>User Hrn :</b> {{user_hrn}}<br>
+This email is only for OneLab admins.
+
NEW AUTHORITY REQUEST
Site : {{site_name}}
Abreviated name : {{site_abbreviated_name}}
URL : {{site_url}}
-latitude : {{site_latitude}}
-longitude : {{site_longitude}}
-Address : {{address_line1}}
- {{address_line2}}
- {{address_line3}}
City : {{address_city}}
-Postcode : {{address_postalcode}}
-State : {{address_state}}
Country : {{address_country}}
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}}
+ Slice name: {{request.slice_name}} -- Url: {{request.number_of_nodes}} -- Email: {{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 %}
-<img src="https://onelab.eu/templates/onelab2/images/logo.png">
+<img src="{{ STATIC_URL }}img/onelab.png">
<br>
<h1>NEW USER REQUEST</h1>
<br>
-{% extends "layout-unfold1.html" %}
+{% extends "layout.html" %}
-{% block unfold_main %}
+{% block content %}
- <h1>Slice created !</h1>
+ <h1>Slice created</h1>
-As you are a PI of the site, you slice has directly been created.
+As you are a manager of your institution, your slice has directly been created.
{% endblock %}
--- /dev/null
+<img src="{{ STATIC_URL }}img/onelab.png">
+<br>
+<p>Dear OneLab user,</p>
+<p></p>
+<p>You have recently requested a slice in the OneLab portal. We are sorry to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.</p>
+<p></p>
+<p>On behalf of the entire team, I wish you a fruitful user experience on OneLab.</p>
+<p></p>
+<p>Yours sincerely,</p>
+<p></p>
+<p>Timur Friedman</p>
+<p>Executive Director</p>
+
--- /dev/null
+Dear OneLab user,
+
+You have recently requested a slice in the OneLab portal. We are sorry to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.
+
+On behalf of the entire team, I wish you a fruitful user experience on OneLab..
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
-<img src="https://onelab.eu/templates/onelab2/images/logo.png">
+<img src="{{ STATIC_URL }}img/onelab.png">
<br>
<h1>NEW SLICE REQUEST</h1>
<br>
+<p>You are receiving this request because we have you listed as a manager at an organization that uses OneLab.</p>
+<p>A user from your organization has requested the creation of a new slice, which will allow him or her to reserve testbed resources to conduct an experiment.</p>
+<br>
<b>Slice name :</b> {{slice_name}}</br>
<b>URL :</b> {{url}}</br>
<b>Purpose :</b> {{purpose}}</br>
<b>Organization :</b> {{organization}}</br>
<b>Email :</b> {{email}}</br>
<b>Portal url :</b> {{current_site}}</br>
+<p></p>
+<p>You can see new slice request <a href="http://{{current_site}}/portal/validate">in the portal.</a><p>
+<p>Please be sure that you know the user who is requesting this slice, as you are responsible for his or her actions, as described in the
+<a href="http://{{current_site}}/terms">OneLab terms and conditions.</a></p>
+<p>And kindly ensure that the stated experiment purpose is clear, and, if there is a website that explains the website, that a URL is provided.</p>
+<p>OneLab and its affiliated testbeds exist purely to support useful and interesting work. To ensure the future of these environments, we need to know what work is actually being done.</p>
+<p></p>
+<p>If you believe that you have received this message in error, or if you have any questions, kindly contact support@onelab.eu.</p>
+
NEW SLICE REQUEST
+You are receiving this request because we have you listed as a manager at an organization that uses OneLab.
+A user from your organization has requested the creation of a new slice, which will allow him or her to reserve testbed resources to conduct an experiment.
+
Slice name : {{slice_name}}
URL : {{url}}
Purpose : {{purpose}}
Organization : {{organization}}
Portal url : {{current_site}}
+You can see new slice request in: http://{{current_site}}/portal/validate
+Please be sure that you know the user who is requesting this slice, as you are responsible for his or her actions, as described in the OneLab terms and conditions:
+ http://{{current_site}}/terms
+
+And kindly ensure that the stated experiment purpose is clear, and, if there is a website that explains the website, that a URL is provided.
+OneLab and its affiliated testbeds exist purely to support useful and interesting work. To ensure the future of these environments, we need to know what work is actually being done.
+
+If you believe that you have received this message in error, or if you have any questions, kindly contact support@onelab.eu.
+
--- /dev/null
+<img src="{{ STATIC_URL }}img/onelab.png">
+<br>
+<p>Dear OneLab user,</p>
+<p></p>
+<p>You have recently requested a slice in the OneLab portal.</p>
+<br>
+<b>Slice name :</b> {{slice_name}}<br>
+<b>URL :</b> {{number_of_nodes}}<br>
+<b>Purpose :</b> {{purpose}}<br>
+<p></p>
+<p>We are glad to inform you that, a manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.</p>
+<p></p>
+<p>On behalf of the entire team, I wish you a fruitful user experience on OneLab.</p>
+<p></p>
+<p>Yours sincerely,</p>
+
+<p>Timur Friedman</p>
+<p>Executive Director</p>
+
+
--- /dev/null
+Dear OneLab user,
+
+You have recently requested a slice in the OneLab portal.
+
+Slice name : {{slice_name}}
+URL : {{number_of_nodes}}
+Purpose : {{purpose}}
+
+We are glad to inform you that, a manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.
+
+On behalf of the entire team, I wish you a fruitful user experience on OneLab.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
+
--- /dev/null
+<img src="{{ STATIC_URL }}img/onelab.png">
+<br>
+<p>Dear {{first_name}} {{last_name}},</p>
+<p></p>
+<p>You have recently registered as a user to OneLab portal. We are sorry to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.</p>
+<p></p>
+<p>On behalf of the entire team, I wish you all the best.</p>
+<p></p>
+<p>Yours sincerely,</p>
+<p></p>
+<p>Timur Friedman</p>
+<p>Executive Director</p>
+
--- /dev/null
+Dear {{first_name}} {{last_name}},
+
+You have recently registered as a user to OneLab portal. We are sorry to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.
+
+On behalf of the entire team, I wish you all the best.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
--- /dev/null
+<img src="{{ STATIC_URL }}img/onelab.png">
+<br>
+<p>Dear {{first_name}} {{last_name}},</p>
+<p></p>
+<p>It is my pleasure to welcome you as a fully signed up user of the OneLab experimental facility. OneLab provides you with access to world class computer networking testbeds, such as IoT-LAB, NITOS, and PlanetLab Europe. Our aim at OneLab is to promote the use of these testbeds for pre-commercial research and development by industry, for scientific research, and for university level laboratory exercises.</p>
+<p></p>
+</p>
+Your entry point for access to the testbeds is the OneLab portal, which provides a web-based interface for browsing and reserving resources on the various testbeds. To run an experiment using those resources, you may log in to the testbed and/or individual nodes on the testbed with your OneLab public/private key pair, or use an experiment control tool such as as NEPI or OMF. The OneLab operations team is standing by at support@onelab.eu to provide you with help regarding the portal and to refer your testbed- and tool-specific queries to those best able to answer them.
+</p>
+<p></p>
+</p>On behalf of the entire team, I wish you a fruitful user experience on OneLab.</p>
+<p></p>
+<p>Yours sincerely,</p>
+<p></p>
+<p>Timur Friedman</p>
+<p>Executive Director</p>
--- /dev/null
+Dear {{first_name}} {{last_name}},
+
+It is my pleasure to welcome you as a fully signed up user of the OneLab experimental facility. OneLab provides you with access to world class computer networking testbeds, such as IoT-LAB, NITOS, and PlanetLab Europe. Our aim at OneLab is to promote the use of these testbeds for pre-commercial research and development by industry, for scientific research, and for university level laboratory exercises.
+
+Your entry point for access to the testbeds is the OneLab portal, which provides a web-based interface for browsing and reserving resources on the various testbeds. To run an experiment using those resources, you may log in to the testbed and/or individual nodes on the testbed with your OneLab public/private key pair, or use an experiment control tool such as as NEPI or OMF. The OneLab operations team is standing by at support@onelab.eu to provide you with help regarding the portal and to refer your testbed- and tool-specific queries to those best able to answer them.
+
+On behalf of the entire team, I wish you a fruitful user experience on OneLab.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director