Updated email templates and made them configurable in /etc.

Change-Id: I4dbce8f179511a779594fe2b05640c003005c813
This commit is contained in:
Dale Smith 2016-03-16 15:54:47 +00:00
parent a4b02b2ae8
commit bc3f08bb4a
9 changed files with 74 additions and 58 deletions

View File

@ -111,7 +111,7 @@ DEFAULT_TASK_SETTINGS:
TASK_SETTINGS:
create_project:
# Additonal actions for views:
# - The order of the actions matters. These will run after the
# - The order of the actions matters. These will run after the
# default action, in the given order.
actions:
- AddAdminToProject
@ -134,7 +134,7 @@ TASK_SETTINGS:
# To not send this email, set the value to null
initial: null
token:
subject: Invitation to an OpenStack Project
subject: Invitation to an OpenStack project
template: invite_user_token.txt
completed:
subject: Invitation Completed
@ -162,10 +162,10 @@ TASK_SETTINGS:
emails:
initial: null
token:
subject: Setup Your OpenStack Password
subject: Set your OpenStack password
template: initial_password_token.txt
completed:
subject: New User Setup Completed
subject: Welcome to OpenStack!
template: initial_password_completed.txt
errors:
SMTPException:

View File

@ -1,5 +1,8 @@
Hello,
Thank you for joining Openstack!
You have successfully setup your new OpenStack user and should be able to access the dashboard and APIs.
Your account is now active and you can access the dashboard and APIs.
Thank you for using our service.
You can find examples and documentation on using Openstack at http://www.openstack.org/
Kind regards,
The Openstack team

View File

@ -1,8 +1,11 @@
Hello,
You can setup your initial OpenStack user password by following this link:
{{ tokenurl }}{{ token }}/
Almost there!
Once setup you will have access to the web dashboard.
Please follow this link to define your password to access Openstack:
{{ tokenurl }}{{ token }}
Thank you for using our service.
Once this is done you will have access to the dashboard and APIs.
Kind regards,
The Openstack team

View File

@ -1,7 +1,7 @@
Hello,
You have successfully joined the project '{{ task.keystone_user.project_name }}' on Openstack.
You have successfully completed your OpenStack project invitation.
You can switch projects on the dashboard via the project drop down list on the top menu.
When using the command line tools or APIs, you can define the project name and ID you want to connect to.
You should now have access to your new project via the dashboard and APIs.
Thank you for using our service.
Kind regards,
The Openstack team

View File

@ -1,15 +1,10 @@
Hello,
You have been invited by {{ task.keystone_user.username }} to join the project '{{ task.keystone_user.project_name }}' on Openstack.
Please click on this link to accept the invitation: {{ tokenurl }}{{ token }}
Someone has invited you to join their OpenStack project.
Project id: {{ actions.NewUser.project_id }}
Roles:{% for role in actions.NewUser.roles %}
- {{ role }}{% endfor %}
New users will be asked to define a password when accepting the invitation.
Existing users will be added to the project and do not need to provide additional information.
To complete this invitation just follow this link:
{{ tokenurl }}{{ token }}/
This link will expire automatically in 24 hours. If expired, you will need to request another one from the person who invited you.
If you are a new user you will just have to setup your password for a user with this email address, but if you already have a user, you simply have to confirm your invitation.
This link will expire in 24 hours at which point you will need to request another one from the person who invited you.
Thank you for using our service.
Kind regards,
The Openstack team

View File

@ -1,7 +1,6 @@
Hello,
This email is to confirm that your Openstack account password has now been changed.
You have successfully reset your OpenStack user password.
If you did not request this password change, please get in touch with your systems administrator to report suspicious activity and secure your account.
If you did not request this reset get in touch with your infrastructure admins.
Thank you for using our service.
Kind regards,
The Openstack team

View File

@ -1,10 +1,13 @@
Hello,
To reset your OpenStack user password follow this link:
{{ tokenurl }}{{ token }}/
We have received a request to reset your Openstack password.
This link will expire in 24 hours at which point you will need to request another one.
Please click the link below to reset your password:
{{ tokenurl }}{{ token }}
If you did not request this reset, either ignore this email and allow it to expire, or get in touch with your infrastructure admins if you are worried.
This link will expire automatically in 24 hours. If expired, you will need to request your password to be reset again.
Thank you for using our service.
If you did not request this password change, please get in touch with your systems administrator to report suspicious activity and secure your account.
Kind regards,
The Openstack team

View File

@ -48,13 +48,18 @@ def send_email(task, email_conf, token=None):
if not email_conf:
return
template = loader.get_template(email_conf['template'])
text_template = loader.get_template(
email_conf['template'],
using='include_etc_templates')
html_template = email_conf.get('html_template', None)
if html_template:
html_template = loader.get_template(html_template)
html_template = loader.get_template(
html_template,
using='include_etc_templates')
emails = set()
actions = {}
# find our set of emails and actions that require email
for action in task.actions:
act = action.get_action()
email = act.get_email()
@ -71,27 +76,24 @@ def send_email(task, email_conf, token=None):
create_notification(task, notes, error=True)
return
context = {
'task': task,
'actions': actions
}
if token:
context = {
'task': task,
'actions': actions,
context.update({
'tokenurl': settings.TOKEN_SUBMISSION_URL,
'token': token.token,
}
else:
context = {'task': task, 'actions': actions}
'token': token.token
})
try:
message = template.render(context)
message = text_template.render(context)
html_message = None
if html_template:
html_message = html_template.render(context)
send_mail(
email_conf['subject'], message, email_conf['reply'],
[emails.pop()], fail_silently=False, html_message=html_message)
else:
send_mail(
email_conf['subject'], message, email_conf['reply'],
[emails.pop()], fail_silently=False)
send_mail(
email_conf['subject'], message, email_conf['reply'],
[emails.pop()], fail_silently=False, html_message=html_message)
except SMTPException as e:
notes = {
'errors':

View File

@ -29,9 +29,6 @@ import yaml
from stacktask.utils import setup_task_settings
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_DEBUG = True
# Application definition
INSTALLED_APPS = (
@ -82,6 +79,20 @@ USE_TZ = True
STATIC_URL = '/static/'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'NAME': 'default',
},
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'DIRS': ['/etc/stacktask/templates/'],
'NAME': 'include_etc_templates',
},
]
# Setup of local settings data
if 'test' in sys.argv:
from stacktask import test_settings