From: Loic Baron Date: Mon, 1 Sep 2014 12:32:30 +0000 (+0200) Subject: Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab X-Git-Tag: myslice-1.1~13^2~16 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=2a9dee0af498110faec36675bbd08c84e02b479c;hp=51b5091377a5ab076393d48d7815faa3db623f9b;p=myslice.git Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab --- diff --git a/portal/actions.py b/portal/actions.py index 3fed09d6..0845619f 100644 --- a/portal/actions.py +++ b/portal/actions.py @@ -424,16 +424,37 @@ def portal_reject_request(wsgi_request, request_ids): 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() @@ -462,7 +483,37 @@ def portal_reject_request(wsgi_request, request_ids): 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 } @@ -527,9 +578,24 @@ def create_slice(wsgi_request, request): 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 @@ -542,8 +608,9 @@ def create_pending_slice(wsgi_request, request, email): 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() @@ -654,9 +721,25 @@ def sfa_create_user(wsgi_request, request, namespace = None, as_admin = False): 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): diff --git a/portal/joinview.py b/portal/joinview.py index 832055bd..0282e962 100644 --- a/portal/joinview.py +++ b/portal/joinview.py @@ -141,7 +141,7 @@ class JoinView (FreeAccessView, ThemeView): 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, @@ -197,14 +197,7 @@ class JoinView (FreeAccessView, ThemeView): '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, @@ -213,33 +206,33 @@ class JoinView (FreeAccessView, ThemeView): '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) diff --git a/portal/templates/authority_request_email.html b/portal/templates/authority_request_email.html index 51b7c401..bdcd065f 100644 --- a/portal/templates/authority_request_email.html +++ b/portal/templates/authority_request_email.html @@ -1,27 +1,24 @@ - +

NEW AUTHORITY REQUEST


+

This email is only for OneLab admins

+

{{site_name}}

-Authority hrn : {{authority_hrn}} -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}} +Authority hrn : {{authority_hrn}}
+Abreviated name : {{site_abbreviated_name}}
+URL : {{site_url}}
+City : {{address_city}}
+Postcode : {{address_postalcode}}
+State : {{address_state}}
+Country : {{address_country}}


PI for this Authority

-First Name : {{first_name}} -Last Name : {{last_name}} -Authority hrn: {{authority_hrn}} -Public key : {{public_key}} -Email : {{email}} -User Hrn : {{user_hrn}} +First Name : {{first_name}}
+Last Name : {{last_name}}
+Authority hrn: {{authority_hrn}}
+Public key : {{public_key}}
+Email : {{email}}
+User Hrn : {{user_hrn}}
diff --git a/portal/templates/authority_request_email.txt b/portal/templates/authority_request_email.txt index 25eb21b5..9376a652 100644 --- a/portal/templates/authority_request_email.txt +++ b/portal/templates/authority_request_email.txt @@ -1,3 +1,5 @@ +This email is only for OneLab admins. + NEW AUTHORITY REQUEST Site : {{site_name}} @@ -6,15 +8,8 @@ Authority hrn : {{authority_hrn}} 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}} diff --git a/portal/templates/management-tab-requests.html b/portal/templates/management-tab-requests.html index c570c7cd..346ecb03 100644 --- a/portal/templates/management-tab-requests.html +++ b/portal/templates/management-tab-requests.html @@ -122,7 +122,7 @@ 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 %} diff --git a/portal/templates/onelab/onelab_user_request_email.html b/portal/templates/onelab/onelab_user_request_email.html index 4786a5cf..de110379 100644 --- a/portal/templates/onelab/onelab_user_request_email.html +++ b/portal/templates/onelab/onelab_user_request_email.html @@ -1,4 +1,4 @@ - +

NEW USER REQUEST


diff --git a/portal/templates/slice-request-done-view.html b/portal/templates/slice-request-done-view.html index f3293ad4..9419d136 100644 --- a/portal/templates/slice-request-done-view.html +++ b/portal/templates/slice-request-done-view.html @@ -1,10 +1,10 @@ -{% extends "layout-unfold1.html" %} +{% extends "layout.html" %} -{% block unfold_main %} +{% block content %} -

Slice created !

+

Slice created

-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 %} diff --git a/portal/templates/slice_request_denied.html b/portal/templates/slice_request_denied.html new file mode 100644 index 00000000..d9ebaadf --- /dev/null +++ b/portal/templates/slice_request_denied.html @@ -0,0 +1,13 @@ + +
+

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

+ diff --git a/portal/templates/slice_request_denied.txt b/portal/templates/slice_request_denied.txt new file mode 100644 index 00000000..c2587df2 --- /dev/null +++ b/portal/templates/slice_request_denied.txt @@ -0,0 +1,11 @@ +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 + diff --git a/portal/templates/slice_request_email.html b/portal/templates/slice_request_email.html index 2c4da62e..3f5f68fe 100644 --- a/portal/templates/slice_request_email.html +++ b/portal/templates/slice_request_email.html @@ -1,11 +1,23 @@ - +

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}}
Email : {{email}}
Portal url : {{current_site}}
+

+

You can see new slice request in the portal.

+

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.

+

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.

+ diff --git a/portal/templates/slice_request_email.txt b/portal/templates/slice_request_email.txt index dfe4f120..997e7529 100644 --- a/portal/templates/slice_request_email.txt +++ b/portal/templates/slice_request_email.txt @@ -1,5 +1,8 @@ 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}} @@ -7,3 +10,12 @@ Email : {{email}} 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. + diff --git a/portal/templates/slice_request_validated.html b/portal/templates/slice_request_validated.html new file mode 100644 index 00000000..9c18227c --- /dev/null +++ b/portal/templates/slice_request_validated.html @@ -0,0 +1,20 @@ + +
+

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

+ + diff --git a/portal/templates/slice_request_validated.txt b/portal/templates/slice_request_validated.txt new file mode 100644 index 00000000..f0cd3c5c --- /dev/null +++ b/portal/templates/slice_request_validated.txt @@ -0,0 +1,18 @@ +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 + + diff --git a/portal/templates/user_request_denied.html b/portal/templates/user_request_denied.html new file mode 100644 index 00000000..9b954f72 --- /dev/null +++ b/portal/templates/user_request_denied.html @@ -0,0 +1,13 @@ + +
+

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

+ diff --git a/portal/templates/user_request_denied.txt b/portal/templates/user_request_denied.txt new file mode 100644 index 00000000..9f931a2c --- /dev/null +++ b/portal/templates/user_request_denied.txt @@ -0,0 +1,11 @@ +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 + diff --git a/portal/templates/user_request_validated.html b/portal/templates/user_request_validated.html new file mode 100644 index 00000000..be979413 --- /dev/null +++ b/portal/templates/user_request_validated.html @@ -0,0 +1,16 @@ + +
+

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

diff --git a/portal/templates/user_request_validated.txt b/portal/templates/user_request_validated.txt new file mode 100644 index 00000000..a9f956aa --- /dev/null +++ b/portal/templates/user_request_validated.txt @@ -0,0 +1,12 @@ +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