Skip to content

Commit 81e638c

Browse files
committed
Emails for manage team "Settings"
1 parent c10f65b commit 81e638c

File tree

8 files changed

+119
-37
lines changed

8 files changed

+119
-37
lines changed

tests/unit/email/test_init.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,6 +2891,7 @@ def team(self, pyramid_user):
28912891
("email_template_name", "send_team_email"),
28922892
[
28932893
("team-created", email.send_team_created_email),
2894+
("team-deleted", email.send_team_deleted_email),
28942895
],
28952896
)
28962897
def test_send_team_email(

tests/unit/manage/test_views.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4518,22 +4518,22 @@ def test_delete_team(
45184518
db_request.POST = MultiDict({"confirm_team_name": team.name})
45194519
db_request.route_path = pretend.call_recorder(lambda *a, **kw: "/foo/bar/")
45204520

4521-
# send_email = pretend.call_recorder(lambda *a, **kw: None)
4522-
# monkeypatch.setattr(views, "send_team_deleted_email", send_email)
4521+
send_email = pretend.call_recorder(lambda *a, **kw: None)
4522+
monkeypatch.setattr(views, "send_team_deleted_email", send_email)
45234523

45244524
view = views.ManageTeamSettingsViews(team, db_request)
45254525
result = view.delete_team()
45264526

45274527
assert isinstance(result, HTTPSeeOther)
45284528
assert result.headers["Location"] == "/foo/bar/"
4529-
# assert send_email.calls == [
4530-
# pretend.call(
4531-
# db_request,
4532-
# {},
4533-
# organization_name=team.organization.name,
4534-
# team_name=team.name,
4535-
# ),
4536-
# ]
4529+
assert send_email.calls == [
4530+
pretend.call(
4531+
db_request,
4532+
set(),
4533+
organization_name=team.organization.name,
4534+
team_name=team.name,
4535+
),
4536+
]
45374537

45384538
def test_delete_team_no_confirm(
45394539
self,

warehouse/email/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,14 @@ def send_team_created_email(request, user, *, organization_name, team_name):
591591
}
592592

593593

594+
@_email("team-deleted")
595+
def send_team_deleted_email(request, user, *, organization_name, team_name):
596+
return {
597+
"organization_name": organization_name,
598+
"team_name": team_name,
599+
}
600+
601+
594602
@_email("team-member-added")
595603
def send_team_member_added_email(
596604
request,

warehouse/locale/messages.pot

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ msgstr ""
116116
msgid "Successful WebAuthn assertion"
117117
msgstr ""
118118

119-
#: warehouse/accounts/views.py:447 warehouse/manage/views.py:903
119+
#: warehouse/accounts/views.py:447 warehouse/manage/views.py:904
120120
msgid "Recovery code accepted. The supplied code cannot be used again."
121121
msgstr ""
122122

@@ -327,69 +327,69 @@ msgstr ""
327327
msgid "This team name has already been used. Choose a different team name."
328328
msgstr ""
329329

330-
#: warehouse/manage/views.py:334
330+
#: warehouse/manage/views.py:335
331331
msgid "Email ${email_address} added - check your email for a verification link"
332332
msgstr ""
333333

334-
#: warehouse/manage/views.py:851
334+
#: warehouse/manage/views.py:852
335335
msgid "Recovery codes already generated"
336336
msgstr ""
337337

338-
#: warehouse/manage/views.py:852
338+
#: warehouse/manage/views.py:853
339339
msgid "Generating new recovery codes will invalidate your existing codes."
340340
msgstr ""
341341

342-
#: warehouse/manage/views.py:1762
342+
#: warehouse/manage/views.py:1763
343343
msgid "User '${username}' already has ${role_name} role for organization"
344344
msgstr ""
345345

346-
#: warehouse/manage/views.py:1773
346+
#: warehouse/manage/views.py:1774
347347
msgid ""
348348
"User '${username}' does not have a verified primary email address and "
349349
"cannot be added as a ${role_name} for organization"
350350
msgstr ""
351351

352-
#: warehouse/manage/views.py:1787 warehouse/manage/views.py:3631
352+
#: warehouse/manage/views.py:1788 warehouse/manage/views.py:3632
353353
msgid "User '${username}' already has an active invite. Please try again later."
354354
msgstr ""
355355

356-
#: warehouse/manage/views.py:1844 warehouse/manage/views.py:3689
356+
#: warehouse/manage/views.py:1845 warehouse/manage/views.py:3690
357357
msgid "Invitation sent to '${username}'"
358358
msgstr ""
359359

360-
#: warehouse/manage/views.py:1887
360+
#: warehouse/manage/views.py:1888
361361
msgid "Could not find organization invitation."
362362
msgstr ""
363363

364-
#: warehouse/manage/views.py:1901 warehouse/manage/views.py:3747
364+
#: warehouse/manage/views.py:1902 warehouse/manage/views.py:3748
365365
msgid "Invitation already expired."
366366
msgstr ""
367367

368-
#: warehouse/manage/views.py:1934 warehouse/manage/views.py:3771
368+
#: warehouse/manage/views.py:1935 warehouse/manage/views.py:3772
369369
msgid "Invitation revoked from '${username}'."
370370
msgstr ""
371371

372-
#: warehouse/manage/views.py:2321
372+
#: warehouse/manage/views.py:2322
373373
msgid "User '${username}' is already a team member"
374374
msgstr ""
375375

376-
#: warehouse/manage/views.py:2702
376+
#: warehouse/manage/views.py:2703
377377
msgid ""
378378
"There have been too many attempted OpenID Connect registrations. Try "
379379
"again later."
380380
msgstr ""
381381

382-
#: warehouse/manage/views.py:3607
382+
#: warehouse/manage/views.py:3608
383383
msgid "User '${username}' already has ${role_name} role for project"
384384
msgstr ""
385385

386-
#: warehouse/manage/views.py:3618
386+
#: warehouse/manage/views.py:3619
387387
msgid ""
388388
"User '${username}' does not have a verified primary email address and "
389389
"cannot be added as a ${role_name} for project"
390390
msgstr ""
391391

392-
#: warehouse/manage/views.py:3736
392+
#: warehouse/manage/views.py:3737
393393
msgid "Could not find role invitation."
394394
msgstr ""
395395

@@ -2013,13 +2013,21 @@ msgid ""
20132013
msgstr ""
20142014

20152015
#: warehouse/templates/email/team-created/body.html:24
2016+
#: warehouse/templates/email/team-deleted/body.html:24
20162017
#: warehouse/templates/email/team-member-added/body.html:24
20172018
#: warehouse/templates/email/team-member-removed/body.html:24
20182019
msgid ""
20192020
"You are receiving this because you are an owner or a manager of the "
20202021
"organization."
20212022
msgstr ""
20222023

2024+
#: warehouse/templates/email/team-deleted/body.html:18
2025+
#, python-format
2026+
msgid ""
2027+
"A team named \"%(team_name)s\" has been deleted in the "
2028+
"\"%(organization_name)s\" organization."
2029+
msgstr ""
2030+
20232031
#: warehouse/templates/email/team-member-added/body.html:18
20242032
#, python-format
20252033
msgid ""

warehouse/manage/views.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
send_role_changed_as_collaborator_email,
7878
send_role_changed_as_organization_member_email,
7979
send_team_created_email,
80+
send_team_deleted_email,
8081
send_team_member_added_email,
8182
send_team_member_removed_email,
8283
send_two_factor_added_email,
@@ -2179,17 +2180,17 @@ def delete_team(self):
21792180
},
21802181
)
21812182

2182-
# TODO Send notification emails.
2183-
# owner_and_manager_users = set(
2184-
# organization_owners(self.request, organization)
2185-
# + organization_managers(self.request, organization)
2186-
# )
2187-
# send_team_deleted_email(
2188-
# self.request,
2189-
# owner_and_manager_users,
2190-
# organization_name=organization.name,
2191-
# team_name=team_name,
2192-
# )
2183+
# Send notification emails.
2184+
owner_and_manager_users = set(
2185+
organization_owners(self.request, organization)
2186+
+ organization_managers(self.request, organization)
2187+
)
2188+
send_team_deleted_email(
2189+
self.request,
2190+
owner_and_manager_users,
2191+
organization_name=organization.name,
2192+
team_name=team_name,
2193+
)
21932194

21942195
# Display notification message.
21952196
self.request.session.flash("Team deleted", queue="success")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
-#}
14+
{% extends "email/_base/body.html" %}
15+
16+
{% block content %}
17+
<p>
18+
{% trans organization_name=organization_name, team_name=team_name %}A team named "{{ team_name }}" has been deleted in the "{{ organization_name }}" organization.{% endtrans %}
19+
</p>
20+
{% endblock %}
21+
22+
23+
{% block reason %}
24+
{% trans %}You are receiving this because you are an owner or a manager of the organization.{% endtrans %}
25+
{% endblock %}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
-#}
14+
{% extends "email/_base/body.txt" %}
15+
16+
{% block content %}
17+
{% trans organization_name=organization_name, team_name=team_name %}A team named "{{ team_name }}" has been deleted in the "{{ organization_name }}" organization.{% endtrans %}
18+
{% endblock %}
19+
20+
{% block reason %}
21+
{% trans %}You are receiving this because you are an owner or a manager of the organization.{% endtrans %}
22+
{% endblock %}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
-#}
14+
15+
{% extends "email/_base/subject.txt" %}
16+
17+
{% block subject %}{% trans %}Team deleted notification{% endtrans %}{% endblock %}

0 commit comments

Comments
 (0)