From bcabdbb7f82edda3c09c66d6ea04fba6ee915d16 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Wed, 6 Dec 2023 12:53:36 +0100 Subject: [PATCH] fix rebase --- lemarche/templates/tenders/_list_item_buyer.html | 2 +- .../management/commands/send_author_incremental_emails.py | 4 ++-- .../commands/send_author_transactioned_question_emails.py | 6 ++++-- ...063_tender_status_sent.py => 0064_tender_status_sent.py} | 2 +- lemarche/tenders/models.py | 6 +++--- lemarche/www/tenders/tasks.py | 4 ++-- 6 files changed, 13 insertions(+), 11 deletions(-) rename lemarche/tenders/migrations/{0063_tender_status_sent.py => 0064_tender_status_sent.py} (94%) diff --git a/lemarche/templates/tenders/_list_item_buyer.html b/lemarche/templates/tenders/_list_item_buyer.html index 2ea06d275..9887e8407 100644 --- a/lemarche/templates/tenders/_list_item_buyer.html +++ b/lemarche/templates/tenders/_list_item_buyer.html @@ -36,7 +36,7 @@

{{ tender.title }}

{% if tender.is_sent %}
- PubliƩ le {{ tender.validated_at|date }} + PubliƩ le {{ tender.sent_at|date }}
{% endif %} diff --git a/lemarche/tenders/management/commands/send_author_incremental_emails.py b/lemarche/tenders/management/commands/send_author_incremental_emails.py index c43fde580..585e0df1b 100644 --- a/lemarche/tenders/management/commands/send_author_incremental_emails.py +++ b/lemarche/tenders/management/commands/send_author_incremental_emails.py @@ -29,8 +29,8 @@ def handle(self, dry_run=False, **options): two_days_ago = timezone.now() - timedelta(days=2) three_days_ago = timezone.now() - timedelta(days=3) tender_sent_incremental = Tender.objects.sent().is_incremental() - tender_sent_incremental_2_days = tender_sent_incremental.filter(created_at__gte=three_days_ago).filter( - created_at__lt=two_days_ago + tender_sent_incremental_2_days = tender_sent_incremental.filter(sent_at__gte=three_days_ago).filter( + sent_at__lt=two_days_ago ) self.stdout.write(f"Found {tender_sent_incremental_2_days.count()} Tenders") diff --git a/lemarche/tenders/management/commands/send_author_transactioned_question_emails.py b/lemarche/tenders/management/commands/send_author_transactioned_question_emails.py index 66eb1516e..780cbfa16 100644 --- a/lemarche/tenders/management/commands/send_author_transactioned_question_emails.py +++ b/lemarche/tenders/management/commands/send_author_transactioned_question_emails.py @@ -35,8 +35,10 @@ def handle(self, kind=None, dry_run=False, is_all_tenders=False, **options): self.stdout.write("-" * 80) start_date_feature = datetime(2022, 6, 23).date() # we first filter on validated tenders - tender_qs = Tender.objects.transaction_survey_email(kind=kind, all=is_all_tenders).filter( - deadline_date__gte=start_date_feature + tender_qs = ( + Tender.objects.sent() + .transaction_survey_email(kind=kind, all=is_all_tenders) + .filter(deadline_date__gte=start_date_feature) ) self.stdout.write(f"Found {tender_qs.count()} tenders") diff --git a/lemarche/tenders/migrations/0063_tender_status_sent.py b/lemarche/tenders/migrations/0064_tender_status_sent.py similarity index 94% rename from lemarche/tenders/migrations/0063_tender_status_sent.py rename to lemarche/tenders/migrations/0064_tender_status_sent.py index 3d14a8022..5a5d1af41 100644 --- a/lemarche/tenders/migrations/0063_tender_status_sent.py +++ b/lemarche/tenders/migrations/0064_tender_status_sent.py @@ -14,7 +14,7 @@ def populate_tenders_sent_status(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ("tenders", "0062_tender_rename_kind_quote_display"), + ("tenders", "0063_tender_distance_location"), ] operations = [ diff --git a/lemarche/tenders/models.py b/lemarche/tenders/models.py index b546dcbcb..ef85e86db 100644 --- a/lemarche/tenders/models.py +++ b/lemarche/tenders/models.py @@ -89,11 +89,11 @@ def in_sectors(self, sectors): def filter_with_siaes(self, siaes): """ - Return the list of tenders corresponding to the list of Siaes + Return the list of tenders corresponding to the list of + - we return only sent tenders - the tender-siae matching has already been done with filter_with_tender() - - we return only validated tenders """ - return self.filter(tendersiae__siae__in=siaes).sent().distinct() + return self.sent().filter(tendersiae__siae__in=siaes).distinct() def with_deadline_date_is_outdated(self, limit_date=datetime.today()): return self.annotate( diff --git a/lemarche/www/tenders/tasks.py b/lemarche/www/tenders/tasks.py index 2d51527c6..3748dd473 100644 --- a/lemarche/www/tenders/tasks.py +++ b/lemarche/www/tenders/tasks.py @@ -466,7 +466,7 @@ def send_author_incremental_2_days_email(tender: Tender): variables = { "TENDER_AUTHOR_FIRST_NAME": tender.author.first_name, "TENDER_TITLE": tender.title, - "TENDER_VALIDATE_AT": tender.validated_at.strftime("%d %B %Y"), + "TENDER_VALIDATE_AT": tender.sent_at.strftime("%d %B %Y"), # TODO: TENDER_SENT_AT? "TENDER_KIND": tender.get_kind_display(), } @@ -500,7 +500,7 @@ def send_tenders_author_feedback_or_survey(tender: Tender, kind="feedback_30d"): variables = { "TENDER_AUTHOR_FIRST_NAME": tender.author.first_name, "TENDER_TITLE": tender.title, - "TENDER_VALIDATE_AT": tender.validated_at.strftime("%d %B %Y"), + "TENDER_VALIDATE_AT": tender.sent_at.strftime("%d %B %Y"), # TODO: TENDER_SENT_AT? "TENDER_KIND": tender.get_kind_display(), }