From 16dfe4b783606dbb11d60d6973b67cc20c62228f Mon Sep 17 00:00:00 2001 From: Jonas Hagberg Date: Sat, 4 Jan 2025 09:48:02 +0100 Subject: [PATCH] Refactor status determination logic in get_yearly_reports function - Enhanced the logic for determining the status of genebanks based on the presence of males and females with certificates. - Introduced specific status messages for cases where no males or females are present, improving clarity and user feedback. - This change aims to provide more accurate and informative status updates for genebank management, enhancing the overall user experience. --- app/utils/data_access.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/utils/data_access.py b/app/utils/data_access.py index 76a721a8..c4ffc3f4 100644 --- a/app/utils/data_access.py +++ b/app/utils/data_access.py @@ -2492,11 +2492,15 @@ def get_yearly_reports(round_id: int, genebank_id: int) -> List[Dict]: status = "Aktiv genbank" # Default status if form_data.get("endingGenbank", False): status = "Vill avsluta genbank" - elif ( - form_data.get("numberOfMalesWithCertificate", 0) == 0 - or form_data.get("numberOfFemalesWithCertificate", 0) == 0 - ): - status = "Avslutad, men kvar som medlem" + else: + males = form_data.get("numberOfMalesWithCertificate", 0) + females = form_data.get("numberOfFemalesWithCertificate", 0) + if males == 0 and females == 0: + status = "Automatisk avslutad: Saknar djur med intyg" + elif males == 0: + status = "Automatisk avslutad: Saknar hane med intyg" + elif females == 0: + status = "Automatisk avslutad: Saknar hona med intyg" # Format publish information based on allowPublication array publish_info = "Nej, ingen publicering"