Skip to content

Commit 11018a0

Browse files
committed
Fix linter issues and generate translations
1 parent c7ec3b5 commit 11018a0

File tree

8 files changed

+263
-174
lines changed

8 files changed

+263
-174
lines changed

tests/functional/test_templates.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def test_render_templates():
9898
try:
9999
env.get_template(rel_file)
100100
except Exception as e:
101-
print(rel_file)
102101
exceptions.append(e)
103102

104103
assert len(exceptions) == 0

tests/unit/manage/test_views.py

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,10 +3607,22 @@ def test_change_role(self, db_request, monkeypatch):
36073607
)
36083608
db_request.route_path = pretend.call_recorder(lambda *a, **kw: "/the-redirect")
36093609

3610-
send_collaborator_role_changed_email = pretend.call_recorder(lambda *a, **kw: None)
3611-
monkeypatch.setattr(views, "send_collaborator_role_changed_email", send_collaborator_role_changed_email)
3612-
send_role_changed_as_collaborator_email = pretend.call_recorder(lambda *a, **kw: None)
3613-
monkeypatch.setattr(views, "send_role_changed_as_collaborator_email", send_role_changed_as_collaborator_email)
3610+
send_collaborator_role_changed_email = pretend.call_recorder(
3611+
lambda *a, **kw: None
3612+
)
3613+
monkeypatch.setattr(
3614+
views,
3615+
"send_collaborator_role_changed_email",
3616+
send_collaborator_role_changed_email,
3617+
)
3618+
send_role_changed_as_collaborator_email = pretend.call_recorder(
3619+
lambda *a, **kw: None
3620+
)
3621+
monkeypatch.setattr(
3622+
views,
3623+
"send_role_changed_as_collaborator_email",
3624+
send_role_changed_as_collaborator_email,
3625+
)
36143626

36153627
result = views.change_project_role(project, db_request)
36163628

@@ -3730,9 +3742,17 @@ def test_delete_role(self, db_request, monkeypatch):
37303742
db_request.route_path = pretend.call_recorder(lambda *a, **kw: "/the-redirect")
37313743

37323744
send_collaborator_removed_email = pretend.call_recorder(lambda *a, **kw: None)
3733-
monkeypatch.setattr(views, "send_collaborator_removed_email", send_collaborator_removed_email)
3734-
send_removed_as_collaborator_email = pretend.call_recorder(lambda *a, **kw: None)
3735-
monkeypatch.setattr(views, "send_removed_as_collaborator_email", send_removed_as_collaborator_email)
3745+
monkeypatch.setattr(
3746+
views, "send_collaborator_removed_email", send_collaborator_removed_email
3747+
)
3748+
send_removed_as_collaborator_email = pretend.call_recorder(
3749+
lambda *a, **kw: None
3750+
)
3751+
monkeypatch.setattr(
3752+
views,
3753+
"send_removed_as_collaborator_email",
3754+
send_removed_as_collaborator_email,
3755+
)
37363756

37373757
result = views.delete_project_role(project, db_request)
37383758

@@ -3742,20 +3762,11 @@ def test_delete_role(self, db_request, monkeypatch):
37423762
assert db_request.db.query(Role).all() == []
37433763
assert send_collaborator_removed_email.calls == [
37443764
pretend.call(
3745-
db_request,
3746-
set(),
3747-
user=user,
3748-
submitter=user_2,
3749-
project_name="foobar",
3765+
db_request, set(), user=user, submitter=user_2, project_name="foobar",
37503766
)
37513767
]
37523768
assert send_removed_as_collaborator_email.calls == [
3753-
pretend.call(
3754-
db_request,
3755-
user,
3756-
submitter=user_2,
3757-
project_name="foobar",
3758-
)
3769+
pretend.call(db_request, user, submitter=user_2, project_name="foobar",)
37593770
]
37603771
assert db_request.session.flash.calls == [
37613772
pretend.call("Removed role", queue="success")

warehouse/locale/messages.pot

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,25 +175,25 @@ msgstr ""
175175
msgid "Email address ${email_address} verified. ${confirm_message}."
176176
msgstr ""
177177

178-
#: warehouse/manage/views.py:190
178+
#: warehouse/manage/views.py:194
179179
msgid "Email ${email_address} added - check your email for a verification link"
180180
msgstr ""
181181

182-
#: warehouse/manage/views.py:671 warehouse/manage/views.py:707
182+
#: warehouse/manage/views.py:675 warehouse/manage/views.py:711
183183
msgid ""
184184
"You must provision a two factor method before recovery codes can be "
185185
"generated"
186186
msgstr ""
187187

188-
#: warehouse/manage/views.py:682
188+
#: warehouse/manage/views.py:686
189189
msgid "Recovery codes already generated"
190190
msgstr ""
191191

192-
#: warehouse/manage/views.py:683
192+
#: warehouse/manage/views.py:687
193193
msgid "Generating new recovery codes will invalidate your existing codes."
194194
msgstr ""
195195

196-
#: warehouse/manage/views.py:734
196+
#: warehouse/manage/views.py:738
197197
msgid "Invalid credentials. Try again"
198198
msgstr ""
199199

@@ -1127,6 +1127,51 @@ msgid ""
11271127
"project on %(site)s."
11281128
msgstr ""
11291129

1130+
#: warehouse/templates/email/collaborator-removed/body.html:27
1131+
#, python-format
1132+
msgid ""
1133+
"\n"
1134+
" A collaborator was removed from a project you own on %(site)s:\n"
1135+
" \n"
1136+
" <ul class=\"collaborator-details\">\n"
1137+
" <li><strong>Username</strong>: %(username)s</li>\n"
1138+
" <li><strong>Collaborator for</strong>: %(project)s</li>\n"
1139+
" <li><strong>Removed by</strong>: %(submitter)s</li>\n"
1140+
" </ul>\n"
1141+
" </p>\n"
1142+
" "
1143+
msgstr ""
1144+
1145+
#: warehouse/templates/email/collaborator-removed/body.html:38
1146+
#: warehouse/templates/email/collaborator-role-changed/body.html:39
1147+
#, python-format
1148+
msgid ""
1149+
"If this was a mistake, you can email <a "
1150+
"href=\"%(admin_mail)s\">[email protected]</a> to communicate with the PyPI "
1151+
"administrators."
1152+
msgstr ""
1153+
1154+
#: warehouse/templates/email/collaborator-removed/body.html:43
1155+
#: warehouse/templates/email/collaborator-role-changed/body.html:44
1156+
msgid "You are receiving this because you are an owner of this project."
1157+
msgstr ""
1158+
1159+
#: warehouse/templates/email/collaborator-role-changed/body.html:27
1160+
#, python-format
1161+
msgid ""
1162+
"\n"
1163+
" A collaborator's role was changed on a project you own on %(site)s:\n"
1164+
" \n"
1165+
" <ul class=\"collaborator-details\">\n"
1166+
" <li><strong>Username</strong>: %(username)s</li>\n"
1167+
" <li><strong>New role</strong>: %(role)s</li>\n"
1168+
" <li><strong>Collaborator for</strong>: %(project)s</li>\n"
1169+
" <li><strong>Changed by</strong>: %(submitter)s</li>\n"
1170+
" </ul>\n"
1171+
" </p>\n"
1172+
" "
1173+
msgstr ""
1174+
11301175
#: warehouse/templates/email/password-change/body.html:18
11311176
#, python-format
11321177
msgid ""
@@ -1267,6 +1312,44 @@ msgid ""
12671312
"<code>%(new_email)s</code>"
12681313
msgstr ""
12691314

1315+
#: warehouse/templates/email/removed-as-collaborator/body.html:19
1316+
#, python-format
1317+
msgid ""
1318+
"You have been removed as collaborator by %(submitter)s from %(project)s "
1319+
"on %(site)s."
1320+
msgstr ""
1321+
1322+
#: warehouse/templates/email/removed-as-collaborator/body.html:24
1323+
#, python-format
1324+
msgid ""
1325+
"You are receiving this because you were removed as a collaborator by "
1326+
"%(submitter)s from %(project)s."
1327+
msgstr ""
1328+
1329+
#: warehouse/templates/email/role-changed-as-collaborator/body.html:20
1330+
#, python-format
1331+
msgid "Your role in the %(project)s project has been changed by %(submitter)s."
1332+
msgstr ""
1333+
1334+
#: warehouse/templates/email/role-changed-as-collaborator/body.html:23
1335+
msgid ""
1336+
"You are now a project owner. You can add other collaborators, upload "
1337+
"releases and delete files, releases or the entire project."
1338+
msgstr ""
1339+
1340+
#: warehouse/templates/email/role-changed-as-collaborator/body.html:25
1341+
msgid ""
1342+
"You are now a project maintainer. You can upload releases but cannot add "
1343+
"collaborators, delete files, releases or the project."
1344+
msgstr ""
1345+
1346+
#: warehouse/templates/email/role-changed-as-collaborator/body.html:32
1347+
#, python-format
1348+
msgid ""
1349+
"You are receiving this because your role was changed by %(submitter)s on "
1350+
"the %(project)s project."
1351+
msgstr ""
1352+
12701353
#: warehouse/templates/email/two-factor-added/body.html:18
12711354
#, python-format
12721355
msgid ""

warehouse/manage/views.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,8 @@ def change_project_role(project, request, _form_class=ChangeRoleForm):
15601560
.all()
15611561
)
15621562
owner_users = {owner.user for owner in owner_roles}
1563-
# Don't send owner notification email to new user if they are now an owner
1563+
# Don't send owner notification email to new user
1564+
# if they are now an owner
15641565
owner_users.discard(role.user)
15651566
send_collaborator_role_changed_email(
15661567
request,
@@ -1608,7 +1609,6 @@ def delete_project_role(project, request):
16081609
if removing_self:
16091610
request.session.flash("Cannot remove yourself as Owner", queue="error")
16101611
else:
1611-
role_user = role.user
16121612
request.db.delete(role)
16131613
request.db.add(
16141614
JournalEntry(
@@ -1627,7 +1627,7 @@ def delete_project_role(project, request):
16271627
"target_user": role.user.username,
16281628
},
16291629
)
1630-
1630+
16311631
owner_roles = (
16321632
request.db.query(Role)
16331633
.filter(Role.project == project)
@@ -1644,10 +1644,7 @@ def delete_project_role(project, request):
16441644
)
16451645

16461646
send_removed_as_collaborator_email(
1647-
request,
1648-
role.user,
1649-
submitter=request.user,
1650-
project_name=project.name,
1647+
request, role.user, submitter=request.user, project_name=project.name,
16511648
)
16521649

16531650
request.session.flash("Removed role", queue="success")
Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
{#
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-
{% set site = request.registry.settings["site.name"] %}
16-
17-
18-
{% block extra_style %}
19-
ul.collaborator-details {
20-
list-style-type: none;
21-
}
22-
{% endblock %}
23-
24-
25-
{% block content %}
26-
<p>
27-
{% trans username=username, project=project, submitter=submitter, site=site %}
28-
A collaborator was removed from a project you own on {{ site }}:
29-
30-
<ul class="collaborator-details">
31-
<li><strong>Username</strong>: {{ username }}</li>
32-
<li><strong>Collaborator for</strong>: {{ project }}</li>
33-
<li><strong>Removed by</strong>: {{ submitter }}</li>
34-
</ul>
35-
</p>
36-
{% endtrans %}
37-
38-
<p>{% trans admin_mail="mailto:[email protected]" %}If this was a mistake, you can email <a href="{{ admin_mail }}">[email protected]</a> to communicate with the PyPI administrators.{% endtrans %}</p>
39-
{% endblock %}
40-
41-
42-
{% block reason %}
43-
{% trans %}You are receiving this because you are an owner of this project.{% endtrans %}
44-
{% endblock %}
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+
{% set site = request.registry.settings["site.name"] %}
16+
17+
18+
{% block extra_style %}
19+
ul.collaborator-details {
20+
list-style-type: none;
21+
}
22+
{% endblock %}
23+
24+
25+
{% block content %}
26+
<p>
27+
{% trans username=username, project=project, submitter=submitter, site=site %}
28+
A collaborator was removed from a project you own on {{ site }}:
29+
30+
<ul class="collaborator-details">
31+
<li><strong>Username</strong>: {{ username }}</li>
32+
<li><strong>Collaborator for</strong>: {{ project }}</li>
33+
<li><strong>Removed by</strong>: {{ submitter }}</li>
34+
</ul>
35+
</p>
36+
{% endtrans %}
37+
38+
<p>{% trans admin_mail="mailto:[email protected]" %}If this was a mistake, you can email <a href="{{ admin_mail }}">[email protected]</a> to communicate with the PyPI administrators.{% endtrans %}</p>
39+
{% endblock %}
40+
41+
42+
{% block reason %}
43+
{% trans %}You are receiving this because you are an owner of this project.{% endtrans %}
44+
{% endblock %}
4545

0 commit comments

Comments
 (0)