Skip to content

Commit

Permalink
Ajout champ Nutriments
Browse files Browse the repository at this point in the history
  • Loading branch information
qloridant committed Jan 9, 2025
1 parent 6f90ac1 commit d35102a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/serializers/declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class OpenDataDeclarationSerializer(serializers.ModelSerializer):
declared_microorganisms = serializers.SerializerMethodField()
declared_substances = serializers.SerializerMethodField()
declared_additives = serializers.SerializerMethodField()
declared_nutriments = serializers.SerializerMethodField()

modification_date = serializers.DateTimeField(format="%Y-%m-%d")

Expand All @@ -329,6 +330,7 @@ class Meta:
"declared_plants",
"declared_microorganisms",
"declared_additives",
"declared_nutriments",
"declared_substances",
"modification_date",
)
Expand Down Expand Up @@ -413,6 +415,12 @@ def get_declared_additives(self, obj):
for declared_ingredient in obj.declared_ingredients.filter(ingredient__ingredient_type=2)
]

def get_declared_nutriments(self, obj):
return [
str(declared_ingredient.ingredient.name)
for declared_ingredient in obj.declared_ingredients.filter(ingredient__ingredient_type=1)
]


class DeclarationSerializer(serializers.ModelSerializer):
def __init__(self, *args, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions data/etl/transformer_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __init__(self):
"declared_microorganisms": "micro_organismes",
"declared_substances": "substances",
"declared_additives": "additifs",
"declared_nutriments": "nutriments",
"modification_date": "date_decision", # Warning : Se baser sur la du snapshot d'autorisation si la plateforme Compl'Alim permet d'editer la déclaration (ex: abandon)
}

Expand Down

0 comments on commit d35102a

Please sign in to comment.