Skip to content

Commit

Permalink
'add_to_contact_list' est appelée après la création d'un tender
Browse files Browse the repository at this point in the history
  • Loading branch information
chloend committed Oct 9, 2024
1 parent 60b9bf4 commit 0f768d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lemarche/api/tenders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -73,14 +74,16 @@ 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(),
source=tender_source,
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
Expand Down
3 changes: 3 additions & 0 deletions lemarche/www/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion lemarche/www/tenders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 0f768d2

Please sign in to comment.