Skip to content

Commit

Permalink
refactor(Emails): enlève les logs en double suite à TemplateTransacti…
Browse files Browse the repository at this point in the history
…onalSendLogs (#1357)
  • Loading branch information
raphodn authored Jul 25, 2024
1 parent 88fa396 commit b440362
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 234 deletions.
18 changes: 2 additions & 16 deletions lemarche/siaes/tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.urls import reverse_lazy
from django.utils import timezone
from huey.contrib.djhuey import task

from lemarche.conversations.models import TemplateTransactional
Expand Down Expand Up @@ -47,6 +46,8 @@ def send_completion_reminder_email_to_siae(siae):
"SIAE_USER_FIRST_NAME": siae_user.first_name,
"SIAE_ID": siae.id,
"SIAE_NAME": siae.name_display,
"SIAE_CONTACT_EMAIL": siae.contact_email,
"SIAE_SECTOR_COUNT": siae.sector_count,
"SIAE_URL": get_object_share_url(siae),
"SIAE_EDIT_URL": f"https://{get_domain_url()}{reverse_lazy('dashboard_siaes:siae_edit_contact', args=[siae.slug])}", # noqa
}
Expand All @@ -58,18 +59,3 @@ def send_completion_reminder_email_to_siae(siae):
recipient_content_object=siae_user,
parent_content_object=siae,
)

# log email
log_item = {
"action": "email_completion_reminder",
"email_template": email_template.code,
"email_to": recipient_list,
# "email_body": email_body,
"email_timestamp": timezone.now().isoformat(),
"metadata": {
"sector_count": siae.sector_count,
"contact_email": True if len(siae.contact_email) else False,
},
}
siae.logs.append(log_item)
siae.save()
67 changes: 0 additions & 67 deletions lemarche/www/dashboard_siaes/tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.urls import reverse_lazy
from django.utils import timezone

from lemarche.conversations.models import TemplateTransactional
from lemarche.utils.emails import whitelist_recipient_list
Expand Down Expand Up @@ -35,17 +34,6 @@ def send_siae_user_request_email_to_assignee(siae_user_request):
parent_content_object=siae_user_request,
)

# log email
log_item = {
"action": "email_sent",
"email_template": email_template.code,
"email_to": recipient_email,
# "email_body": email_body,
"email_timestamp": timezone.now().isoformat(),
}
siae_user_request.logs.append(log_item)
siae_user_request.save()


def send_siae_user_request_response_email_to_initiator(siae_user_request):
"""
Expand Down Expand Up @@ -81,17 +69,6 @@ def send_siae_user_request_response_email_to_initiator(siae_user_request):
parent_content_object=siae_user_request,
)

# log email
log_item = {
"action": "email_sent",
"email_template": email_template.code,
"email_to": recipient_email,
# "email_body": email_body,
"email_timestamp": timezone.now().isoformat(),
}
siae_user_request.logs.append(log_item)
siae_user_request.save()


def send_siae_user_request_reminder_3_days_emails(siae_user_request):
"""
Expand Down Expand Up @@ -129,17 +106,6 @@ def send_siae_user_request_reminder_3_days_email_to_assignee(siae_user_request):
parent_content_object=siae_user_request,
)

# log email
log_item = {
"action": "email_sent",
"email_template": email_template.code,
"email_to": recipient_email,
# "email_body": email_body,
"email_timestamp": timezone.now().isoformat(),
}
siae_user_request.logs.append(log_item)
siae_user_request.save()


def send_siae_user_request_reminder_3_days_email_to_initiator(siae_user_request):
email_template = TemplateTransactional.objects.get(code="SIAEUSERREQUEST_REMINDER_1_INITIATOR")
Expand All @@ -166,17 +132,6 @@ def send_siae_user_request_reminder_3_days_email_to_initiator(siae_user_request)
parent_content_object=siae_user_request,
)

# log email
log_item = {
"action": "email_sent",
"email_template": email_template.code,
"email_to": recipient_email,
# "email_body": email_body,
"email_timestamp": timezone.now().isoformat(),
}
siae_user_request.logs.append(log_item)
siae_user_request.save()


def send_siae_user_request_reminder_8_days_emails(siae_user_request):
"""
Expand Down Expand Up @@ -214,17 +169,6 @@ def send_siae_user_request_reminder_8_days_email_to_assignee(siae_user_request):
parent_content_object=siae_user_request,
)

# log email
log_item = {
"action": "email_sent",
"email_template": email_template.code,
"email_to": recipient_email,
# "email_body": email_body,
"email_timestamp": timezone.now().isoformat(),
}
siae_user_request.logs.append(log_item)
siae_user_request.save()


def send_siae_user_request_reminder_8_days_email_to_initiator(siae_user_request):
email_template = TemplateTransactional.objects.get(code="SIAEUSERREQUEST_REMINDER_2_INITIATOR")
Expand All @@ -251,14 +195,3 @@ def send_siae_user_request_reminder_8_days_email_to_initiator(siae_user_request)
recipient_content_object=siae_user_request.initiator,
parent_content_object=siae_user_request,
)

# log email
log_item = {
"action": "email_sent",
"email_template": email_template.code,
"email_to": recipient_email,
# "email_body": email_body,
"email_timestamp": timezone.now().isoformat(),
}
siae_user_request.logs.append(log_item)
siae_user_request.save()
Loading

0 comments on commit b440362

Please sign in to comment.