Skip to content

Commit f0c23f3

Browse files
committed
TemplateTransactionalSendLog: add content_object (Siae, User)
1 parent 5a1ae57 commit f0c23f3

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

lemarche/conversations/models.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ def send_transactional_email(
267267
subject=None,
268268
from_email=settings.DEFAULT_FROM_EMAIL,
269269
from_name=settings.DEFAULT_FROM_NAME,
270+
content_object=None,
270271
):
271272
if self.is_active:
272273
args = {
@@ -283,7 +284,9 @@ def send_transactional_email(
283284
elif self.source == conversation_constants.SOURCE_BREVO:
284285
result = api_brevo.send_transactional_email_with_template(**args)
285286
# create log
286-
self.create_send_log(extra_data={"source": self.source, "args": args, "response": result()})
287+
self.create_send_log(
288+
content_object=content_object, extra_data={"source": self.source, "args": args, "response": result()}
289+
)
287290

288291

289292
class TemplateTransactionalSendLog(models.Model):

lemarche/siaes/tasks.py

+3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def send_completion_reminder_email_to_siae(siae):
4343
recipient_name = siae_user.full_name
4444

4545
variables = {
46+
"SIAE_USER_ID": siae_user.id,
4647
"SIAE_USER_FIRST_NAME": siae_user.first_name,
48+
"SIAE_ID": siae.id,
4749
"SIAE_NAME": siae.name_display,
4850
"SIAE_URL": get_object_share_url(siae),
4951
"SIAE_EDIT_URL": f"https://{get_domain_url()}{reverse_lazy('dashboard_siaes:siae_edit_contact', args=[siae.slug])}", # noqa
@@ -53,6 +55,7 @@ def send_completion_reminder_email_to_siae(siae):
5355
recipient_email=recipient_email,
5456
recipient_name=recipient_name,
5557
variables=variables,
58+
content_object=siae_user,
5659
)
5760

5861
# log email

lemarche/www/auth/tasks.py

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def send_new_user_password_reset_link(user: User):
4949
recipient_name = user.full_name
5050

5151
variables = {
52+
"USER_ID": user.id,
5253
"USER_FIRST_NAME": user.first_name,
5354
"USER_EMAIL": user.email,
5455
"PASSWORD_RESET_LINK": generate_password_reset_link(user),
@@ -58,4 +59,5 @@ def send_new_user_password_reset_link(user: User):
5859
recipient_email=recipient_email,
5960
recipient_name=recipient_name,
6061
variables=variables,
62+
content_object=user,
6163
)

lemarche/www/dashboard_siaes/tasks.py

+12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def send_siae_user_request_email_to_assignee(siae_user_request):
1717
recipient_name = siae_user_request.assignee.full_name
1818

1919
variables = {
20+
"SIAE_USER_REQUEST_ID": siae_user_request.id,
2021
"ASSIGNEE_ID": siae_user_request.assignee.id,
2122
"ASSIGNEE_FULL_NAME": siae_user_request.assignee.full_name,
2223
"INITIATIOR_ID": siae_user_request.initiator.id,
@@ -30,6 +31,7 @@ def send_siae_user_request_email_to_assignee(siae_user_request):
3031
recipient_email=recipient_email,
3132
recipient_name=recipient_name,
3233
variables=variables,
34+
content_object=siae_user_request.assignee,
3335
)
3436

3537
# log email
@@ -60,6 +62,7 @@ def send_siae_user_request_response_email_to_initiator(siae_user_request):
6062
recipient_name = siae_user_request.initiator.full_name
6163

6264
variables = {
65+
"SIAE_USER_REQUEST_ID": siae_user_request.id,
6366
"ASSIGNEE_ID": siae_user_request.assignee.id,
6467
"ASSIGNEE_FULL_NAME": siae_user_request.assignee.full_name,
6568
"INITIATIOR_ID": siae_user_request.initiator.id,
@@ -73,6 +76,7 @@ def send_siae_user_request_response_email_to_initiator(siae_user_request):
7376
recipient_email=recipient_email,
7477
recipient_name=recipient_name,
7578
variables=variables,
79+
content_object=siae_user_request.initiator,
7680
)
7781

7882
# log email
@@ -105,6 +109,7 @@ def send_siae_user_request_reminder_3_days_email_to_assignee(siae_user_request):
105109
recipient_name = siae_user_request.assignee.full_name
106110

107111
variables = {
112+
"SIAE_USER_REQUEST_ID": siae_user_request.id,
108113
"ASSIGNEE_ID": siae_user_request.assignee.id,
109114
"ASSIGNEE_FULL_NAME": siae_user_request.assignee.full_name,
110115
"INITIATIOR_ID": siae_user_request.initiator.id,
@@ -118,6 +123,7 @@ def send_siae_user_request_reminder_3_days_email_to_assignee(siae_user_request):
118123
recipient_email=recipient_email,
119124
recipient_name=recipient_name,
120125
variables=variables,
126+
content_object=siae_user_request.assignee,
121127
)
122128

123129
# log email
@@ -140,6 +146,7 @@ def send_siae_user_request_reminder_3_days_email_to_initiator(siae_user_request)
140146
recipient_name = siae_user_request.initiator.full_name
141147

142148
variables = {
149+
"SIAE_USER_REQUEST_ID": siae_user_request.id,
143150
"ASSIGNEE_ID": siae_user_request.assignee.id,
144151
"ASSIGNEE_FULL_NAME": siae_user_request.assignee.full_name,
145152
"INITIATIOR_ID": siae_user_request.initiator.id,
@@ -152,6 +159,7 @@ def send_siae_user_request_reminder_3_days_email_to_initiator(siae_user_request)
152159
recipient_email=recipient_email,
153160
recipient_name=recipient_name,
154161
variables=variables,
162+
content_object=siae_user_request.initiator,
155163
)
156164

157165
# log email
@@ -184,6 +192,7 @@ def send_siae_user_request_reminder_8_days_email_to_assignee(siae_user_request):
184192
recipient_name = siae_user_request.assignee.full_name
185193

186194
variables = {
195+
"SIAE_USER_REQUEST_ID": siae_user_request.id,
187196
"ASSIGNEE_ID": siae_user_request.assignee.id,
188197
"ASSIGNEE_FULL_NAME": siae_user_request.assignee.full_name,
189198
"INITIATIOR_ID": siae_user_request.initiator.id,
@@ -197,6 +206,7 @@ def send_siae_user_request_reminder_8_days_email_to_assignee(siae_user_request):
197206
recipient_email=recipient_email,
198207
recipient_name=recipient_name,
199208
variables=variables,
209+
content_object=siae_user_request.assignee,
200210
)
201211

202212
# log email
@@ -219,6 +229,7 @@ def send_siae_user_request_reminder_8_days_email_to_initiator(siae_user_request)
219229
recipient_name = siae_user_request.initiator.full_name
220230

221231
variables = {
232+
"SIAE_USER_REQUEST_ID": siae_user_request.id,
222233
"ASSIGNEE_ID": siae_user_request.assignee.id,
223234
"ASSIGNEE_FULL_NAME": siae_user_request.assignee.full_name,
224235
"INITIATIOR_ID": siae_user_request.initiator.id,
@@ -232,6 +243,7 @@ def send_siae_user_request_reminder_8_days_email_to_initiator(siae_user_request)
232243
recipient_email=recipient_email,
233244
recipient_name=recipient_name,
234245
variables=variables,
246+
content_object=siae_user_request.initiator,
235247
)
236248

237249
# log email

lemarche/www/tenders/tasks.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ def send_tender_email_to_siae(tender: Tender, siae: Siae, email_subject: str, re
150150
recipient_name=recipient_name,
151151
variables=variables,
152152
subject=email_subject,
153-
from_email=settings.DEFAULT_FROM_EMAIL,
154-
from_name=settings.DEFAULT_FROM_NAME,
153+
content_object=recipient_to_override if recipient_to_override else siae,
155154
)
156155

157156
# update tendersiae
@@ -297,8 +296,7 @@ def send_tender_contacted_reminder_email_to_siae(tendersiae: TenderSiae, email_t
297296
recipient_email=recipient_email,
298297
recipient_name=recipient_name,
299298
variables=variables,
300-
from_email=settings.DEFAULT_FROM_EMAIL,
301-
from_name=settings.DEFAULT_FROM_NAME,
299+
content_object=tendersiae.siae,
302300
)
303301

304302
# log email
@@ -374,8 +372,7 @@ def send_tender_interested_reminder_email_to_siae(
374372
recipient_email=recipient_email,
375373
recipient_name=recipient_name,
376374
variables=variables,
377-
from_email=settings.DEFAULT_FROM_EMAIL,
378-
from_name=settings.DEFAULT_FROM_NAME,
375+
content_object=tendersiae.siae,
379376
)
380377

381378
# log email
@@ -420,6 +417,7 @@ def send_confirmation_published_email_to_author(tender: Tender):
420417
recipient_email=recipient_email,
421418
recipient_name=recipient_name,
422419
variables=variables,
420+
content_object=tender.author,
423421
)
424422

425423
# log email
@@ -486,6 +484,7 @@ def send_siae_interested_email_to_author(tender: Tender):
486484
recipient_email=recipient_email,
487485
recipient_name=recipient_name,
488486
variables=variables,
487+
content_object=tender.author,
489488
)
490489

491490
# log email
@@ -564,6 +563,7 @@ def send_tenders_author_feedback_or_survey(tender: Tender, kind="feedback_30d"):
564563
recipient_email=recipient_email,
565564
recipient_name=recipient_name,
566565
variables=variables,
566+
content_object=tender.author,
567567
)
568568

569569
# log email
@@ -636,6 +636,7 @@ def send_tenders_siae_survey(tendersiae: TenderSiae, kind="transactioned_questio
636636
recipient_email=recipient_email,
637637
recipient_name=recipient_name,
638638
variables=variables,
639+
content_object=user,
639640
)
640641

641642
# update tendersiae
@@ -713,6 +714,7 @@ def send_super_siaes_email_to_author(tender: Tender, top_siaes: list[Siae]):
713714
recipient_email=recipient_email,
714715
recipient_name=recipient_name,
715716
variables=variables,
717+
content_object=tender.author,
716718
)
717719

718720
# log email

0 commit comments

Comments
 (0)