From 7af92c92a7a5687769c56e3c64887edaec4601a2 Mon Sep 17 00:00:00 2001 From: qloridant Date: Sun, 1 Dec 2024 19:51:01 +0100 Subject: [PATCH] Fix: remplacer declared_substance.name par declared_substance.substance.name --- api/serializers/declaration.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/serializers/declaration.py b/api/serializers/declaration.py index ae8bb6ff..8f03e892 100644 --- a/api/serializers/declaration.py +++ b/api/serializers/declaration.py @@ -366,10 +366,12 @@ def get_declared_plants(self, obj): "quantité_par_djr": declared_plant.quantity, "unite": declared_plant.unit.name, } + if declared_plant.unit + else {} for declared_plant in obj.declared_plants.filter(active=True) ] - def get_declared_ingredients(self, obj): + def get_declared_microorganisms(self, obj): return [ { "genre": declared_microorganism.microorganism.genus, @@ -386,11 +388,11 @@ def get_declared_ingredients(self, obj): def get_declared_substances(self, obj): return [ { - "nom": declared_substance.name, + "nom": declared_substance.substance.name, "quantité_par_djr": declared_substance.quantity, "unite": declared_substance.unit.name, } - if declared_substance.name and declared_substance.quantity and declared_substance.unit + if declared_substance.substance.name and declared_substance.quantity and declared_substance.unit else {} for declared_substance in obj.declared_substances.all() ]