Skip to content

Commit 1bfaf2f

Browse files
committed
fix email templates
1 parent 6fc1923 commit 1bfaf2f

26 files changed

Lines changed: 63 additions & 57 deletions

api_tests/identifiers/views/test_identifier_detail.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_identifier_preprint_detail_unpublished(
155155

156156
# test_unpublished_preprint_identifier_readcontrib_authenticated
157157
read_user = AuthUserFactory()
158-
preprint.add_contributor(read_user, READ, save=True)
158+
preprint.add_contributor(read_user, READ, save=True, notification_type=False)
159159
res = app.get(url, auth=read_user.auth, expect_errors=True)
160160
assert res.status_code == 200
161161

@@ -181,7 +181,7 @@ def test_identifier_preprint_detail_deleted(
181181

182182
# test_deleted_preprint_identifier_readcontrib_authenticated
183183
read_user = AuthUserFactory()
184-
preprint.add_contributor(read_user, READ, save=True)
184+
preprint.add_contributor(read_user, READ, save=True, notification_type=False)
185185
res = app.get(url, auth=read_user.auth, expect_errors=True)
186186
assert res.status_code == 404
187187

@@ -207,7 +207,7 @@ def test_identifier_preprint_detail_private(
207207

208208
# test_private_preprint_identifier_readcontrib_authenticated
209209
read_user = AuthUserFactory()
210-
preprint.add_contributor(read_user, READ, save=True)
210+
preprint.add_contributor(read_user, READ, save=True, notification_type=False)
211211
res = app.get(url, auth=read_user.auth, expect_errors=True)
212212
assert res.status_code == 200
213213

@@ -233,7 +233,7 @@ def test_identifier_preprint_detail_abandoned(
233233

234234
# test_abandoned_preprint_identifier_readcontrib_authenticated
235235
read_user = AuthUserFactory()
236-
preprint.add_contributor(read_user, READ, save=True)
236+
preprint.add_contributor(read_user, READ, save=True, notification_type=False)
237237
res = app.get(url, auth=read_user.auth, expect_errors=True)
238238
assert res.status_code == 403
239239

notifications/listeners.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ def queue_first_public_project_email(user, node):
7070
subscribed_object=user,
7171
user=user,
7272
event_context={
73+
'user_fullname': user.fullname,
7374
'domain': settings.DOMAIN,
7475
'nid': node._id,
75-
'fullname': user.fullname,
7676
'project_title': node.title,
7777
'osf_url': settings.DOMAIN,
7878
}

osf/models/collection_submission.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22

33
from django.db import models
4+
from django.utils import timezone
45
from django.utils.functional import cached_property
56
from framework import sentry
67
from framework.exceptions import PermissionsError
@@ -104,17 +105,26 @@ def _notify_contributors_pending(self, event_data):
104105
NotificationType.objects.get(
105106
name=NotificationType.Type.COLLECTION_SUBMISSION_SUBMITTED,
106107
).emit(
108+
is_digest=True,
107109
user=contributor,
108110
subscribed_object=self,
109111
event_context={
110-
'user': contributor.id,
111-
'submitter': user.id,
112+
'requester_contributor_names': ''.join(
113+
self.guid.referent.contributors.values_list('fullname', flat=True)),
114+
'localized_timestamp': str(timezone.now()),
115+
'user_fullname': contributor.fullname,
116+
'submitter_fullname': user.fullname,
117+
'requester_fullname': self.creator.fullname,
118+
'profile_image_url': user.profile_image_url(),
119+
'submitter_absolute_url': user.get_absolute_url(),
120+
'collections_link': settings.DOMAIN + 'collections/' + self.collection.provider._id,
121+
'collection_provider_name': self.collection.provider.name,
112122
'is_initiator': self.creator == contributor,
113123
'is_admin': self.guid.referent.has_permission(contributor, ADMIN),
114124
'is_registered_contrib': contributor.is_registered,
115-
'collection': self.collection.id,
116125
'claim_url': claim_url,
117-
'node': self.guid.referent.id,
126+
'node_title': self.guid.referent.title,
127+
'node_absolute_url': self.guid.referent.get_absolute_url(),
118128
'domain': settings.DOMAIN,
119129
'osf_contact_email': settings.OSF_CONTACT_EMAIL,
120130
},
@@ -128,7 +138,7 @@ def _notify_moderators_pending(self, event_data):
128138
user=user,
129139
subscribed_object=self.guid.referent,
130140
event_context={
131-
'submitter': self.creator.id,
141+
'submitter_fullname': self.creator.fullname,
132142
'requester_contributor_names': ''.join(self.guid.referent.contributors.values_list('fullname', flat=True))
133143
},
134144
is_digest=True,

website/templates/emails/collection_submission_accepted.html.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<p>
77
% if is_admin:
88
Your request to add <a href="${node.absolute_url}">${node.title}</a> to
9-
<a href="${domain + 'collections/' + collection.provider._id}">${collection.provider.name}</a> was approved.
9+
<a href="${domain + 'collections/' + collection.provider._id}">${collection_provider_name}</a> was approved.
1010
% else:
11-
<a href="${node.absolute_url}">${node.title}</a> was added to <a href="${domain + 'collections/' + collection.provider._id}">${collection.provider.name}</a>.
11+
<a href="${node.absolute_url}">${node.title}</a> was added to <a href="${domain + 'collections/' + collection.provider._id}">${collection_provider_name}</a>.
1212
% endif
1313
</p>
1414
<p>

website/templates/emails/collection_submission_cancel.html.mako

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
<br>
77
<p>
88
% if is_admin:
9-
The request to add <a href="${node.absolute_url}">${node.title}</a> to
9+
The request to add <a href="${node_absolute_url}">${node_title}</a> to
1010
% if collection.provider:
11-
<a href="${domain + 'collections/' + collection_provider__id}">${collection_provider_name}</a>
11+
<a href="${collections_link}">${collection_provider_name}</a>
1212
% else:
1313
<a href="${domain + 'myprojects/'}">${collection_provider_name}</a>
1414
% endif
1515
1616
was canceled. If you wish to be associated with the collection, you will need to request to be added again.
1717
% else:
1818
<a href="${remover_absolute_url}">${remover.fullname}</a> canceled the request to add
19-
<a href="${node_absolute_url}">${node.title}</a>to
19+
<a href="${node_absolute_url}">${node_title}</a>to
2020
% if collection.provider:
21-
<a href="${domain + 'collections/' + collection_provider__id}">${collection.provider.name}</a>
21+
<a href="${collections_link}">${collection_provider_name}</a>
2222
% else:
2323
<a href="${domain + 'myprojects/'}">${collection_provider_name}</a>
2424
% endif
@@ -27,7 +27,7 @@
2727
</p>
2828
<p>
2929
If you are not ${user_fullname} or you have been erroneously associated with
30-
<a href="${node.absolute_url}">${node.title}</a>, email ${osf_contact_email} with the subject line
30+
<a href="${node_absolute_url}">${node_title}</a>, email ${osf_contact_email} with the subject line
3131
"Claiming error" to report the problem.
3232
</p>
3333
Sincerely,<br>

website/templates/emails/collection_submission_rejected.html.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
<p>
99
% if is_admin:
1010
Your request to add <a href="${node.absolute_url}">${node.title}</a> to
11-
<a href="${domain + 'collections/' + collection_provider__id}">${collection_provider_name}</a> was not accepted.
11+
<a href="${collections_link}">${collection_provider_name}</a> was not accepted.
1212
<p>
1313
Rejection Justification:
1414
</p>
1515
<p>
1616
${rejection_justification}
1717
</p>
1818
% else:
19-
<a href="${node.absolute_url}">${node.title}</a> was not accepted by <a href="${domain + 'collections/' + collection_provider__id}">${collection.provider.name}</a>.
19+
<a href="${node.absolute_url}">${node.title}</a> was not accepted by <a href="${collections_link}">${collection_provider_name}</a>.
2020
% endif
2121
</p>
2222
<p>

website/templates/emails/collection_submission_removed_admin.html.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<p>
99
% if is_admin:
1010
<a href="${node_absolute_url}">${node_title}</a> was removed from
11-
<a href="${domain + 'collections/' + collection_provider__id}">${collection_provider_name}</a>. If you wish to be associated with the collection, you
11+
<a href="${collections_link}">${collection_provider_name}</a>. If you wish to be associated with the collection, you
1212
will need to reapply to the collection again.
1313
% else:
1414
<a href="${remover_absolute_url}">${remover_fullname}</a> removed

website/templates/emails/collection_submission_removed_moderator.html.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<br>
88
<p>
99
% if is_admin:
10-
<a href="${node.absolute_url}">${node.title}</a> was removed by <a href="${domain + 'collections/' + collection.provider._id}">${collection.provider.name}</a>:
10+
<a href="${node.absolute_url}">${node.title}</a> was removed by <a href="${domain + 'collections/' + collection.provider._id}">${collection_provider_name}</a>:
1111
<br>
1212
<p>
1313
${rejection_justification}
@@ -16,7 +16,7 @@
1616
If you wish to be associated with the collection, you will need to reapply to the collection again.
1717
% else:
1818
<a href="${node.absolute_url}">${node.title}</a> was removed by
19-
<a href="${domain + 'collections/' + collection_provider__id}">${collection_provider_name}</a>
19+
<a href="${collections_link}">${collection_provider_name}</a>
2020
% endif
2121
</p>
2222
<p>

website/templates/emails/collection_submission_removed_private.html.mako

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
You have changed the privacy of <a href="${node.absolute_url}">${node.title}</a> and it has therefore been
1010
removed from
1111
% if collection.provider:
12-
<a href="${domain + 'collections/' + collection.provider._id}">${collection.provider.name}</a>
12+
<a href="${domain + 'collections/' + collection.provider._id}">${collection_provider_name}</a>
1313
% else:
14-
<a href="${domain + 'myprojects/'}">${collection.provider.name}</a>
14+
<a href="${domain + 'myprojects/'}">${collection_provider_name}</a>
1515
% endif
1616
. If you wish to be associated with the collection, you will need to request addition to the collection again.
1717
% else:
1818
<a href="${remover_absolute_url}">${remover_fullname}</a> has changed the privacy settings for
1919
<a href="${node_absolute_url}">${node_title}</a> it has therefore been removed from
2020
% if collection.provider:
21-
<a href="${domain + 'collections/' + collection_provider__id}">${collection_provider_name}</a>
21+
<a href="${collections_link}">${collection_provider_name}</a>
2222
% else:
2323
<a href="${domain + 'myprojects/'}">${collection_provider_name}</a>
2424
% endif

website/templates/emails/collection_submission_submitted.html.mako

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
<br>
77
<p>
88
% if is_initator:
9-
You just started a request to add <a href="${node_absolute_url}">${node.title}</a>
10-
to <a href="${domain + 'collections/' + collection_provider._id}">${collection_provider_name}</a>.
9+
You just started a request to add <a href="${node_absolute_url}">${node_title}</a>
10+
to <a href="${collections_link}">${collection_provider_name}</a>.
1111
All admins and contributors will be notified via email.
1212
% elif is_registered_contrib:
1313
<a href="${submitter_absolute_url}">${submitter_fullname}</a> just included you in <a href="${node_absolute_url}">${node_title}</a> to a request to add
14-
<a href="${node_absolute_url}">${node.title}</a> to
15-
<a href="${domain + 'collections/' + collection_provider__id}">${collection_provider_name}</a>.
14+
<a href="${node_absolute_url}">${node_title}</a> to
15+
<a href="${collections_link}">${collection_provider_name}</a>.
1616
All admins and contributors will be notified via email.
1717
% else:
1818
<a href="${submitter_absolute_url}">${submitter_fullname}</a> included you in a request to add
19-
<a href="${node_absolute_url}">${node_title}</a> to <a href="${domain + 'collections/' + collection_provider__id}">${collection.provider.name}</a>
19+
<a href="${node_absolute_url}">${node_title}</a> to <a href="${collections_link}">${collection_provider_name}</a>
2020
<a href="${claim_url}">Click here to claim account link</a>. After you set a password, you will be able to make
2121
contributions to the project. You will also be able to easily access this and any other project or
2222
component by going to your "My Projects" page. If you decide to not make an account, then it's <b>important

0 commit comments

Comments
 (0)