Browse Source

Fix wording in the invite email when inviting read-only users

pull/783/head
Pēteris Caune 1 year ago
parent
commit
f849c5e1a1
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
  1. 1
      CHANGELOG.md
  2. 8
      hc/accounts/models.py
  3. 13
      hc/accounts/tests/test_project.py
  4. 19
      templates/emails/login-body-html.html
  5. 10
      templates/emails/login-body-text.html
  6. 4
      templates/emails/login-subject.html

1
CHANGELOG.md

@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
- Fix project sort order to be case-insensitive everywhere in the UI (#768)
- Fix special character encoding in project invite emails
- Fix check transfer between same account's projects when at check limit
- Fix wording in the invite email when inviting read-only users
## v2.5 - 2022-12-14

8
hc/accounts/models.py

@ -116,7 +116,7 @@ class Profile(models.Model):
return "login" in self.token and check_password(token, self.token)
def send_instant_login_link(self, inviting_project=None, redirect_url=None):
def send_instant_login_link(self, membership=None, redirect_url=None):
token = self.prepare_token()
path = reverse("hc-check-token", args=[self.user.username, token])
if redirect_url:
@ -125,7 +125,7 @@ class Profile(models.Model):
ctx = {
"button_text": "Sign In",
"button_url": settings.SITE_ROOT + path,
"inviting_project": inviting_project,
"membership": membership,
}
emails.login(self.user.email, ctx)
@ -393,9 +393,9 @@ class Project(models.Model):
if self.owner_id == user.id:
return False
Member.objects.create(user=user, project=self, role=role)
m = Member.objects.create(user=user, project=self, role=role)
checks_url = reverse("hc-checks", args=[self.code])
user.profile.send_instant_login_link(self, redirect_url=checks_url)
user.profile.send_instant_login_link(membership=m, redirect_url=checks_url)
return True
def update_next_nag_dates(self):

13
hc/accounts/tests/test_project.py

@ -115,8 +115,13 @@ class ProjectTestCase(BaseTestCase):
self.assertFalse(member.user.project_set.exists())
# And an email should have been sent
message = mail.outbox[0]
subj = f"You have been invited to join Alice's Project on {settings.SITE_NAME}"
self.assertEqual(mail.outbox[0].subject, subj)
self.assertEqual(message.subject, subj)
html, _ = message.alternatives[0]
self.assertIn("You will be able to manage", message.body)
self.assertIn("You will be able to manage", html)
def test_it_adds_readonly_team_member(self):
self.client.login(username="alice@example.org", password="password")
@ -131,6 +136,12 @@ class ProjectTestCase(BaseTestCase):
self.assertEqual(member.role, member.Role.READONLY)
# And an email should have been sent
message = mail.outbox[0]
html, _ = message.alternatives[0]
self.assertIn("You will be able to view", message.body)
self.assertIn("You will be able to view", html)
def test_it_adds_manager_team_member(self):
self.client.login(username="alice@example.org", password="password")

19
templates/emails/login-body-html.html

@ -5,20 +5,23 @@
Hello,
<br />
{% if inviting_project %}
{% if inviting_project.name %}
<strong>{{ inviting_project.owner.email }}</strong> invites you to their
{% if membership %}
{% if membership.project.name %}
<strong>{{ membership.project.owner.email }}</strong> invites you to their
<a href="{% site_root %}">{% site_name %}</a>
project <strong>{{ inviting_project }}</strong>.
project <strong>{{ membership.project }}</strong>.
{% else %}
<strong>{{ inviting_project.owner.email }}</strong> invites you to their
<strong>{{ membership.project.owner.email }}</strong> invites you to their
<a href="{% site_root %}">{% site_name %}</a> account.
{% endif %}
<br /><br />
You will be able to manage their
existing monitoring checks and set up new ones. If you already have your
own account on {% site_name %}, you will be able to switch
{% if membership.role == "r" %}
You will be able to view their existing monitoring checks, but not modify them.
{% else %}
You will be able to manage their existing monitoring checks and set up new ones.
{% endif %}
If you already have your own account on {% site_name %}, you will be able to switch
between the two accounts.
<br /><br />
{% endif %}

10
templates/emails/login-body-text.html

@ -1,11 +1,13 @@
{% load hc_extras %}
{% block content %}Hello,
{% if inviting_project %}
{{ inviting_project.owner.email }} invites you to their {% site_name %} account.
{% if membership %}
{{ membership.project.owner.email }} invites you to their {% site_name %} account.
You will be able to manage their existing monitoring checks and set up new
ones. If you already have your own account on {% site_name %}, you will
{% if membership.role == "r" %}You will be able to view their existing monitoring checks, but not
modify them.{% else %}You will be able to manage their existing monitoring checks and set up
new ones.{% endif %} If you already have your own account on {% site_name %}, you will
be able to switch between the two accounts.{% endif %}
To log into {% site_name %}, please open the link below:
{{ button_url }}

4
templates/emails/login-subject.html

@ -1,6 +1,6 @@
{% load hc_extras %}
{% if inviting_project %}
You have been invited to join {{ inviting_project|safe }} on {% site_name %}
{% if membership %}
You have been invited to join {{ membership.project|safe }} on {% site_name %}
{% else %}
Log in to {% site_name %}
{% endif %}
Loading…
Cancel
Save