From f1f0a6d87b21d3cd221ef5c99cf816741e968c1b Mon Sep 17 00:00:00 2001 From: adrian-turjak Date: Tue, 23 May 2017 21:36:53 +1200 Subject: [PATCH] Fixing some minor email templating issues * Properly handling the spacing issues in some email templates. * Adding proper cache values as needed by default templates in action so they are set properly, and also work for reapproval. Change-Id: I3c8f9ffce3618b9a32464efa463c3bbd57782c68 --- adjutant/actions/v1/projects.py | 3 +++ adjutant/api/v1/templates/invite_user_token.txt | 2 ++ adjutant/api/v1/templates/signup_completed.txt | 4 +++- adjutant/api/v1/templates/signup_token.txt | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/adjutant/actions/v1/projects.py b/adjutant/actions/v1/projects.py index c08adce..ef82ad9 100644 --- a/adjutant/actions/v1/projects.py +++ b/adjutant/actions/v1/projects.py @@ -193,6 +193,8 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin): else: self.action.valid = False + self.action.task.cache['user_state'] = self.action.state + self.action.save() def _pre_approve(self): @@ -225,6 +227,7 @@ class NewProjectWithUserAction(UserNameAction, ProjectMixin, UserMixin): roles_granted = self.get_cache('roles_granted') if user_id and roles_granted: self.action.task.cache['user_id'] = user_id + self.action.task.cache['user_state'] = self.action.state self.add_note("User already setup.") elif not user_id: self.action.valid = self._validate_user() diff --git a/adjutant/api/v1/templates/invite_user_token.txt b/adjutant/api/v1/templates/invite_user_token.txt index 56c4eeb..0ed2b18 100644 --- a/adjutant/api/v1/templates/invite_user_token.txt +++ b/adjutant/api/v1/templates/invite_user_token.txt @@ -3,6 +3,7 @@ You have been invited by {{ task.keystone_user.username }} to join the project ' Please click on this link to accept the invitation: {{ tokenurl }}{{ token }} +{% spaceless %} {% if task.cache.user_state == "default" %} You will be asked to define a password when accepting the invitation. After that you will be given access to the project and will be able to login. {% elif task.cache.user_state == "existing" %} @@ -10,6 +11,7 @@ As an existing user you will be added to the project and do not need to provide {% elif task.cache.user_state == "disabled" %} It appears you already have a user account that was disabled. We've reactivated it, but because it may have been a while we've reset your password. After you setup your new password you will be given access to the project and will be able to login. {% endif %} +{% endspaceless %} This link will expire automatically after 24 hours. If expired, you will need to request another one from the person who invited you. diff --git a/adjutant/api/v1/templates/signup_completed.txt b/adjutant/api/v1/templates/signup_completed.txt index 187c034..48282dd 100644 --- a/adjutant/api/v1/templates/signup_completed.txt +++ b/adjutant/api/v1/templates/signup_completed.txt @@ -1,3 +1,4 @@ +{% spaceless %} {% if task.cache.user_state == "default" %} This email is to confirm that your Openstack signup has been completed and your new user and password have now been set up. {% elif task.cache.user_state == "existing" %} @@ -5,8 +6,9 @@ This email is to confirm that your Openstack signup has been completed and your {% elif task.cache.user_state == "disabled" %} This email is to confirm that your Openstack signup has been completed and your existing user has been re-enabled and given access to your new project. {% endif %} +{% endspaceless %} If you did not do this yourself, please get in touch with your systems administrator to report suspicious activity and secure your account. Kind regards, -The Openstack team \ No newline at end of file +The Openstack team diff --git a/adjutant/api/v1/templates/signup_token.txt b/adjutant/api/v1/templates/signup_token.txt index 11addff..589abfb 100644 --- a/adjutant/api/v1/templates/signup_token.txt +++ b/adjutant/api/v1/templates/signup_token.txt @@ -3,11 +3,13 @@ Your OpenStack sign-up has been approved! Please follow this link to finalise access to your new OpenStack project: {{ tokenurl }}{{ token }} +{% spaceless %} {% if task.cache.user_state == "default" %} You will be asked to define a password, after that you will be given access to the project and will be able to login {% elif task.cache.user_state == "disabled" %} It appears you already have a user account that was disabled. We've reactivated it, but because it may have been a while we've reset your password. After you setup your new password you will be given access to your new project and will be able to login. {% endif %} +{% endspaceless %} This link expires automatically after 24 hours. If expired, you can simply go to the dashboard and request a password reset.