From 0f768d263b46803fde8698679eba94f0935fbedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9?= Date: Wed, 9 Oct 2024 19:25:19 +0200 Subject: [PATCH] =?UTF-8?q?'add=5Fto=5Fcontact=5Flist'=20est=20appel=C3=A9?= =?UTF-8?q?e=20apr=C3=A8s=20la=20cr=C3=A9ation=20d'un=20tender?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lemarche/api/tenders/views.py | 5 ++++- lemarche/www/pages/views.py | 3 +++ lemarche/www/tenders/views.py | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lemarche/api/tenders/views.py b/lemarche/api/tenders/views.py index 4b3f5c6f0..f22d4d0d2 100644 --- a/lemarche/api/tenders/views.py +++ b/lemarche/api/tenders/views.py @@ -8,6 +8,7 @@ from lemarche.tenders import constants as tender_constants from lemarche.tenders.models import Tender from lemarche.users import constants as user_constants +from lemarche.utils.emails import add_to_contact_list from lemarche.www.tenders.utils import get_or_create_user_from_anonymous_content @@ -73,7 +74,7 @@ def perform_create(self, serializer: TenderSerializer): serializer.validated_data.pop("contact_kind", None) serializer.validated_data.pop("contact_buyer_kind_detail", None) # create Tender - serializer.save( + tender = serializer.save( author=user, status=tender_constants.STATUS_PUBLISHED, published_at=timezone.now(), @@ -81,6 +82,8 @@ def perform_create(self, serializer: TenderSerializer): import_raw_object=self.request.data, ) + add_to_contact_list(user=user, type="signup", source=user_source, tender_id=tender.id) + class TenderKindViewSet(mixins.ListModelMixin, viewsets.GenericViewSet): serializer_class = BasicChoiceSerializer diff --git a/lemarche/www/pages/views.py b/lemarche/www/pages/views.py index 525f012ac..d81e42136 100644 --- a/lemarche/www/pages/views.py +++ b/lemarche/www/pages/views.py @@ -18,6 +18,7 @@ from lemarche.tenders.models import Tender, TenderStepsData from lemarche.users import constants as user_constants from lemarche.users.models import User +from lemarche.utils.emails import add_to_contact_list from lemarche.utils.tracker import track from lemarche.www.pages.forms import ( CompanyReferenceCalculatorForm, @@ -357,6 +358,8 @@ def csrf_failure(request, reason=""): # noqa C901 setattr(tender, attribute, tender_dict.get(attribute)) tender.save() + add_to_contact_list(user=user, type="signup", source=tender_constants.SOURCE_FORM_CSRF, tender_id=tender.id) + # remove steps data uuid = request.session.get("tender_steps_data_uuid", None) if uuid: diff --git a/lemarche/www/tenders/views.py b/lemarche/www/tenders/views.py index 2121b4613..1c86721a8 100644 --- a/lemarche/www/tenders/views.py +++ b/lemarche/www/tenders/views.py @@ -18,6 +18,7 @@ from lemarche.users.models import User from lemarche.utils import constants, settings_context_processors from lemarche.utils.data import get_choice +from lemarche.utils.emails import add_to_contact_list from lemarche.utils.mixins import ( SesameSiaeMemberRequiredMixin, SesameTenderAuthorRequiredMixin, @@ -229,7 +230,7 @@ def done(self, _, form_dict, **kwargs): tender_dict = cleaned_data | {"author": user, "source": tender_constants.SOURCE_FORM} is_draft: bool = self.request.POST.get("is_draft", False) self.save_instance_tender(tender_dict=tender_dict, form_dict=form_dict, is_draft=is_draft) - + tender_id = self.instance.id # remove steps data uuid = self.request.session.get("tender_steps_data_uuid", None) if uuid: @@ -254,6 +255,7 @@ def done(self, _, form_dict, **kwargs): message=self.get_success_message(cleaned_data, self.instance, is_draft=is_draft), extra_tags="modal_message_bizdev", ) + add_to_contact_list(user=user, type="signup", source=user_constants.SOURCE_TENDER_FORM, tender_id=tender_id) return redirect(self.get_success_url()) def get_success_url(self):