from django.http import HttpResponse, HttpResponseRedirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required
-from django.core.mail import send_mail
from theme import ThemeView
from django.contrib.auth.models import User
from django.template.loader import render_to_string
-from django.core.mail import send_mail,EmailMultiAlternatives
+from django.core.mail import EmailMultiAlternatives
from theme import ThemeView
)
s.save()
- # Send an email: the recipients are the PI of the authority
- recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
-
- theme.template_name = 'slice_request_email.txt'
- text_content = render_to_string(theme.template, request)
-
- theme.template_name = 'slice_request_email.html'
- html_content = render_to_string(theme.template, request)
-
- theme.template_name = 'slice_request_email_subject.txt'
- subject = render_to_string(theme.template, request)
- subject = subject.replace('\n', '')
-
- sender = email
- msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
- print msg
- msg.attach_alternative(html_content, "text/html")
- msg.send()
- #send_mail(subject, msg, email, recipients)
+ try:
+ # Send an email: the recipients are the PI of the authority
+ recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
+
+ theme.template_name = 'slice_request_email.txt'
+ text_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'slice_request_email.html'
+ html_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'slice_request_email_subject.txt'
+ subject = render_to_string(theme.template, request)
+ subject = subject.replace('\n', '')
+
+ sender = email
+ msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
+ print msg
+ 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"
#-------------------------------------------------------------------------------
# REQUESTS - Users
except Exception, e:
print "Failed creating manifold account on platform %s for user: %s" % ('myslice', request['email'])
- # Send an email: the recipients are the PI of the authority
- # If No PI is defined for this Authority, send to a default email (different for each theme)
- recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
+ try:
+ # Send an email: the recipients are the PI of the authority
+ # If No PI is defined for this Authority, send to a default email (different for each theme)
+ recipients = authority_get_pi_emails(wsgi_request, request['authority_hrn'])
+
+ theme.template_name = 'user_request_email.html'
+ html_content = render_to_string(theme.template, request)
- theme.template_name = 'user_request_email.html'
- html_content = render_to_string(theme.template, request)
-
- theme.template_name = 'user_request_email.txt'
- text_content = render_to_string(theme.template, request)
-
- theme.template_name = 'user_request_email_subject.txt'
- subject = render_to_string(theme.template, request)
- subject = subject.replace('\n', '')
-
- theme.template_name = 'email_default_sender.txt'
- sender = render_to_string(theme.template, request)
- sender = sender.replace('\n', '')
-
- msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
- msg.attach_alternative(html_content, "text/html")
- msg.send()
+ theme.template_name = 'user_request_email.txt'
+ text_content = render_to_string(theme.template, request)
+
+ theme.template_name = 'user_request_email_subject.txt'
+ subject = render_to_string(theme.template, request)
+ subject = subject.replace('\n', '')
+
+ theme.template_name = 'email_default_sender.txt'
+ sender = render_to_string(theme.template, request)
+ sender = sender.replace('\n', '')
+
+ msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
+ 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"
from django.shortcuts import render
from django.template.loader import render_to_string
from django.views.generic import View
-from django.core.mail import send_mail
from unfold.loginrequired import FreeAccessView
from ui.topmenu import topmenu_items, the_user
email = form.cleaned_data['email'] # email of the sender
cc_myself = form.cleaned_data['cc_myself']
- #recipients = authority_get_pi_emails(authority_hrn)
- recipients = ['support@myslice.info' ]
- if cc_myself:
- recipients.append(email)
+ try:
+ # Send an email: the support recipients
+ theme.template_name = 'email_support.txt'
+ recipients = render_to_string(theme.template, form.cleaned_data)
+ recipients = subject.replace('\n', '')
+ if cc_myself:
+ recipients.append(email)
+
+ theme.template_name = 'contact_support_email.html'
+ html_content = render_to_string(theme.template, form.cleaned_data)
+
+ theme.template_name = 'contact_support_email.txt'
+ text_content = render_to_string(theme.template, form.cleaned_data)
+
+ theme.template_name = 'contact_support_email_subject.txt'
+ subject = render_to_string(theme.template, form.cleaned_data)
+ subject = subject.replace('\n', '')
+
+ if not email:
+ theme.template_name = 'email_default_sender.txt'
+ sender = render_to_string(theme.template, form.cleaned_data)
+ sender = sender.replace('\n', '')
+ else:
+ sender = email
+
+ msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
+ 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"
- msg = render_to_string('contact-support-email.txt', form.cleaned_data)
- send_mail("Onelab user %s submitted a query "%email, msg, email, recipients)
if request.user.is_authenticated() :
username = request.user.email
else :
from random import choice
-from django.core.mail import send_mail
from django.contrib import messages
from django.views.generic import View
from django.shortcuts import render
Generates a one-use only link for resetting password and sends to the
user.
"""
- from django.core.mail import send_mail
- for user in self.users_cache:
- if not domain_override:
- current_site = get_current_site(request)
- site_name = current_site.name
- domain = current_site.domain
- else:
- site_name = domain = domain_override
- c = {
- 'email': user.email,
- 'domain': domain,
- 'site_name': site_name,
- 'uid': int_to_base36(user.pk),
- 'user': user,
- 'token': token_generator.make_token(user),
- 'protocol': use_https and 'https' or 'http',
- }
- subject = loader.render_to_string(subject_template_name, c)
- # Email subject *must not* contain newlines
- subject = ''.join(subject.splitlines())
- email = loader.render_to_string(email_template_name, c)
- send_mail(subject, email, from_email, [user.email])
+ from django.core.mail import send_mail,EmailMultiAlternatives
+ try:
+ for user in self.users_cache:
+ if not domain_override:
+ current_site = get_current_site(request)
+ site_name = current_site.name
+ domain = current_site.domain
+ else:
+ site_name = domain = domain_override
+ c = {
+ 'email': user.email,
+ 'domain': domain,
+ 'site_name': site_name,
+ 'uid': int_to_base36(user.pk),
+ 'user': user,
+ 'token': token_generator.make_token(user),
+ 'protocol': use_https and 'https' or 'http',
+ }
+ subject = loader.render_to_string(subject_template_name, c)
+ # Email subject *must not* contain newlines
+ subject = ''.join(subject.splitlines())
+ email = loader.render_to_string(email_template_name, c)
+ send_mail(subject, email, from_email, [user.email])
+ except Exception, e:
+ print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
class SetPasswordForm(forms.Form):
import json
from random import randint
-from django.core.mail import send_mail
+from django.core.mail import EmailMultiAlternatives
from django.contrib.auth.models import User
from django.views.generic import View
from django.template.loader import render_to_string
user_id = user_detail['user_id']+1 # the user_id for the newly created user in local:user
account_params = {'platform_id': 5, 'user_id': user_id, 'auth_type': auth_type, 'config': account_config}
manifold_add_account(request,account_params)
-
+
# Send email
- ctx = {
- 'first_name' : reg_fname,
- 'last_name' : reg_lname,
- 'authority_hrn' : reg_auth,
- 'email' : reg_email,
- 'user_hrn' : user_hrn,
- 'public_key' : public_key,
- }
- 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'])
-
- msg = render_to_string('user_request_email.txt', ctx)
- send_mail("Onelab New Authority request for %s submitted"%reg_email, msg, 'support@myslice.info', recipients)
+ try:
+ ctx = {
+ 'site_name' : reg_site_name,
+ '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,
+ 'authority_hrn' : reg_auth,
+ 'email' : reg_email,
+ 'user_hrn' : user_hrn,
+ 'public_key' : public_key,
+ }
+ 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)
+
+ theme.template_name = 'authority_request_email.txt'
+ text_content = render_to_string(theme.template, ctx)
+
+ theme.template_name = 'authority_request_email_subject.txt'
+ subject = render_to_string(theme.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])
+ 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 render(request, 'user_register_complete.html')
template_env = {
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required
-from django.core.mail import send_mail
from theme import ThemeView
#
import json, os, re, itertools
import re
from django.conf import settings
-from django.core.mail import send_mail
from django.db import models
from django.db import transaction
from django.utils.translation import ugettext_lazy as _
import json
from random import randint
-from django.core.mail import send_mail
from django.views.generic import View
from django.template.loader import render_to_string
from django.shortcuts import render
--- /dev/null
+<img src="https://onelab.eu/templates/onelab2/images/logo.png">
+<br>
+<h1>NEW AUTHORITY REQUEST</h1>
+<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}}
+
+<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}}
--- /dev/null
+NEW AUTHORITY REQUEST
+
+Site : {{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}}
+
+
+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}}
--- /dev/null
+OneLab new Authority request submitted
--- /dev/null
+User details:
+
+First name : {{first_name}}
+Last name : {{last_name}}
+email : {{email}}
+Authority : {{authority}}
+
+Query Details:
+
+Subject : {{subject}}
+Description : {{description}}
+
--- /dev/null
+OneLab support: user ticket