Skip to content

Commit

Permalink
Send emails if tender needs modification or is rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
chloend committed Dec 15, 2024
1 parent 2a9fc00 commit 320473b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lemarche/tenders/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
from lemarche.utils.admin.admin_site import admin_site
from lemarche.utils.apis import api_brevo
from lemarche.utils.fields import ChoiceArrayField, pretty_print_readonly_jsonfield
from lemarche.www.tenders.tasks import restart_send_tender_task
from lemarche.www.tenders.tasks import (
restart_send_tender_task,
send_tender_author_modification_request,
send_tender_author_reject_message,
)


class KindFilter(MultiChoice):
Expand Down Expand Up @@ -817,6 +821,18 @@ def response_change(self, request, obj: Tender):
# we don't need to send it in the crm, parteners manage them
self.message_user(request, "Ce dépôt de besoin a été validé. Il sera envoyé aux partenaires :)")
return HttpResponseRedirect(".")
if obj.email_sent_for_modification:
if not obj._original_email_sent_for_modification:
send_tender_author_modification_request(tender=obj)
self.message_user(request, "Une demande de modification a été envoyée à l'auteur du besoin")
obj.email_sent_for_modification = True
obj.status = tender_constants.STATUS_DRAFT
obj.save(update_fields=["email_sent_for_modification", "status"])
return HttpResponseRedirect(".")
if obj.status == tender_constants.STATUS_REJECTED:
send_tender_author_reject_message(tender=obj)
self.message_user(request, "Un email a été envoyé à l'auteur du besoin")
return HttpResponseRedirect(".")
elif request.POST.get("_restart_tender"):
restart_send_tender_task(tender=obj)
self.message_user(request, "Ce dépôt de besoin a été renvoyé aux structures")
Expand Down

0 comments on commit 320473b

Please sign in to comment.