-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Issue:
Some foods don't have an FDC ID, especially produces (In this example Lime Peel)
fdc_id is not nullable which throws a validation error if you try to add a food without it.
https://github.com/TandoorRecipes/open_data_plugin/blob/master/models.py#L114
In some other models it seems to be nullable:
https://github.com/TandoorRecipes/open_data_plugin/blob/master/models.py#L82
Request:
{
"version":{
"id":1,
"name":"base",
"code":"base"
},
"slug":"food-lime-peel-raw",
"name":"Lime Peel",
"plural_name":"Lime Peel",
"store_category":{
"id":1,
"version":{
"id":1,
"name":"base",
"code":"base",
"comment":""
},
"slug":"category-produce",
"name":"Produce",
"description":"",
"comment":"Vegetables and fruits. Could be split into those categories.",
"created_by":"szeraax"
},
"preferred_unit_metric":null,
"preferred_shopping_unit_metric":null,
"preferred_unit_imperial":null,
"preferred_shopping_unit_imperial":null,
"properties":[
{
"property":{
"id":6,
"version":{
"id":1,
"name":"base",
"code":"base",
"comment":""
},
"slug":"property-carbohydrates",
"name":"Carbohydrates",
"unit":"g",
"fdc_id":1005,
"comment":"",
"created_by":"vabene1111"
},
"property_amount":"16"
},
{
"property":{
"id":4,
"version":{
"id":1,
"name":"base",
"code":"base",
"comment":""
},
"slug":"property-calories",
"name":"Calories",
"unit":"kcal",
"fdc_id":1008,
"comment":"",
"created_by":"vabene1111"
},
"property_amount":"47"
},
{
"property":{
"id":5,
"version":{
"id":1,
"name":"base",
"code":"base",
"comment":""
},
"slug":"property-proteins",
"name":"Proteins",
"unit":"g",
"fdc_id":1003,
"comment":"",
"created_by":"vabene1111"
},
"property_amount":"1.5"
},
{
"property":{
"id":7,
"version":{
"id":1,
"name":"base",
"code":"base",
"comment":""
},
"slug":"property-fats",
"name":"Fats",
"unit":"g",
"fdc_id":1004,
"comment":"",
"created_by":"vabene1111"
},
"property_amount":"0.3"
}
],
"fdc_id":"",
"comment":"",
"properties_food_amount":"100",
"properties_food_unit":{
"id":1,
"version":{
"id":1,
"name":"base",
"code":"base",
"comment":""
},
"slug":"unit-g",
"name":"g",
"plural_name":"g",
"base_unit":"G",
"type":"WEIGHT",
"comment":"",
"created_by":"vabene1111"
},
"properties_source":"Same as food-lemon-peel-raw"
}
Response:
{"fdc_id":["This field may not be blank."]}
Proposed solution:
Make the field nullable for foods that don't have one
Metadata
Metadata
Assignees
Labels
No labels