mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 11:32:38 +02:00
Do not send emails if all products are in rupture.
This commit is contained in:
parent
541e6dd354
commit
2550030bb6
2 changed files with 13 additions and 8 deletions
|
@ -451,14 +451,15 @@ async def send_referent_emails(request, response, id):
|
|||
email_subject = request.form.get("email_subject")
|
||||
for referent in delivery.get_referents():
|
||||
producers = delivery.get_producers_for_referent(referent)
|
||||
summary = reports.summary(delivery, producers)
|
||||
emails.send(
|
||||
referent,
|
||||
email_subject,
|
||||
email_body,
|
||||
copy=delivery.contact,
|
||||
attachments=[(f"{config.SITE_NAME}-{date}-{referent}.xlsx", summary)],
|
||||
)
|
||||
if any([delivery.producers[p].has_active_products(delivery) for p in producers]):
|
||||
summary = reports.summary(delivery, producers)
|
||||
emails.send(
|
||||
referent,
|
||||
email_subject,
|
||||
email_body,
|
||||
copy=delivery.contact,
|
||||
attachments=[(f"{config.SITE_NAME}-{date}-{referent}.xlsx", summary)],
|
||||
)
|
||||
response.message("Le mail à bien été envoyé")
|
||||
response.redirect = f"/livraison/{id}/gérer"
|
||||
|
||||
|
|
|
@ -168,6 +168,10 @@ class Producer(Base):
|
|||
contact: str = ""
|
||||
description: str = ""
|
||||
|
||||
def has_active_products(self, delivery):
|
||||
products = delivery.get_products_by(self.id)
|
||||
return any([not p.rupture for p in products])
|
||||
|
||||
|
||||
@dataclass
|
||||
class Product(Base):
|
||||
|
|
Loading…
Reference in a new issue