Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dépôt de besoin : fini de réparer l'envoi par batch #1047

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.core.management.base import BaseCommand

from lemarche.tenders.models import Tender
from lemarche.www.tenders.tasks import send_tender_emails_to_siaes, send_validated_tender
from lemarche.www.tenders.tasks import send_validated_sent_batch_tender, send_validated_tender


class Command(BaseCommand):
Expand Down Expand Up @@ -32,4 +32,4 @@ def handle(self, *args, **options):
f"Found {validated_sent_tenders_batch_to_send.count()} validated sent tender(s) to batch"
)
for tender in validated_sent_tenders_batch_to_send:
send_tender_emails_to_siaes(tender)
send_validated_sent_batch_tender(tender)
11 changes: 10 additions & 1 deletion lemarche/www/tenders/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@ def send_validated_tender(tender: Tender):
# send the tender to all matching Siaes & Partners
send_tender_emails_to_siaes(tender)
send_tender_emails_to_partners(tender)
# log
# set first_sent_at & last_sent_at, log
tender.set_sent()
# hubspot
if settings.BITOUBI_ENV == "prod":
api_hubspot.create_deal_from_tender(tender=tender)


def send_validated_sent_batch_tender(tender: Tender):
# the tender has already been sent a first time with send_validated_tender
# this is the second/third/... iteration
send_tender_emails_to_siaes(tender)
# update last_sent_at, log
tender.set_sent()


def restart_send_tender_task(tender: Tender):
# send the tender to all matching Siaes & Partners
send_tender_emails_to_siaes(tender)
Expand Down