Skip to content

Commit

Permalink
Mail log creation on task end
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilouf committed Dec 31, 2024
1 parent daa98f6 commit 7f68ef0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lemarche/users/management/commands/anonymize_old_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def warn_users_by_email(self, warning_date: timezone.datetime, expiry_date: time

# Users that have already received the mail are excluded
users_to_warn = User.objects.filter(last_login__lte=warning_date, is_active=True, is_anonymized=False).exclude(
recipient_transactional_send_logs__template_transactional__code=email_template.code
recipient_transactional_send_logs__template_transactional__code=email_template.code,
recipient_transactional_send_logs__extra_data__contains={"sent": True},
)

if dry_run:
Expand Down
3 changes: 2 additions & 1 deletion lemarche/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.utils import timezone

from lemarche.companies.factories import CompanyFactory
from lemarche.conversations.constants import SOURCE_BREVO
from lemarche.conversations.models import TemplateTransactional, TemplateTransactionalSendLog
from lemarche.favorites.factories import FavoriteListFactory
from lemarche.siaes.factories import SiaeFactory
Expand Down Expand Up @@ -216,7 +217,7 @@ def setUp(self):
first_name="about_to_be_inactive",
)
# Set email as active to check if it's really sent
TemplateTransactional.objects.all().update(is_active=True)
TemplateTransactional.objects.all().update(is_active=True, source=SOURCE_BREVO)

def test_set_inactive_user(self):
"""Select users that last logged for more than a year and flag them as inactive"""
Expand Down

0 comments on commit 7f68ef0

Please sign in to comment.