mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 19:42:37 +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,6 +451,7 @@ 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)
|
||||
if any([delivery.producers[p].has_active_products(delivery) for p in producers]):
|
||||
summary = reports.summary(delivery, producers)
|
||||
emails.send(
|
||||
referent,
|
||||
|
|
|
@ -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