various fixes food serializer
This commit is contained in:
parent
76b1ab9e85
commit
19d152461c
@ -318,6 +318,7 @@ class RecipeSimpleSerializer(serializers.ModelSerializer):
|
||||
|
||||
class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer):
|
||||
supermarket_category = SupermarketCategorySerializer(allow_null=True, required=False)
|
||||
recipe = RecipeSimpleSerializer(allow_null=True, required=False)
|
||||
image = serializers.SerializerMethodField('get_image')
|
||||
numrecipe = serializers.SerializerMethodField('count_recipes')
|
||||
|
||||
@ -339,18 +340,18 @@ class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer):
|
||||
def count_recipes(self, obj):
|
||||
return Recipe.objects.filter(steps__ingredients__food=obj, space=obj.space).count()
|
||||
|
||||
def to_representation(self, instance):
|
||||
response = super().to_representation(instance)
|
||||
# turns a GET of food.recipe into a dict of data while allowing a PATCH/PUT of an integer to update a food with a recipe
|
||||
recipe = RecipeSimpleSerializer(instance.recipe, allow_null=True).data
|
||||
supermarket_category = SupermarketCategorySerializer(instance.supermarket_category, allow_null=True).data
|
||||
response['recipe'] = recipe if recipe else None
|
||||
# the SupermarketCategorySerializer returns a dict instead of None when the column is null
|
||||
if supermarket_category == {'name': ''} or None:
|
||||
response['supermarket_category'] = None
|
||||
else:
|
||||
response['supermarket_category'] = supermarket_category
|
||||
return response
|
||||
# def to_representation(self, instance):
|
||||
# response = super().to_representation(instance)
|
||||
# # turns a GET of food.recipe into a dict of data while allowing a PATCH/PUT of an integer to update a food with a recipe
|
||||
# recipe = RecipeSimpleSerializer(instance.recipe, allow_null=True).data
|
||||
# supermarket_category = SupermarketCategorySerializer(instance.supermarket_category, allow_null=True).data
|
||||
# response['recipe'] = recipe if recipe else None
|
||||
# # the SupermarketCategorySerializer returns a dict instead of None when the column is null
|
||||
# if supermarket_category == {'name': ''} or None:
|
||||
# response['supermarket_category'] = None
|
||||
# else:
|
||||
# response['supermarket_category'] = supermarket_category
|
||||
# return response
|
||||
|
||||
def create(self, validated_data):
|
||||
validated_data['name'] = validated_data['name'].strip()
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,42 +0,0 @@
|
||||
// vetur.config.js
|
||||
/** @type {import('vls').VeturConfig} */
|
||||
module.exports = {
|
||||
// **optional** default: `{}`
|
||||
// override vscode settings
|
||||
// Notice: It only affects the settings used by Vetur.
|
||||
settings: {
|
||||
"vetur.useWorkspaceDependencies": true,
|
||||
"vetur.experimental.templateInterpolationService": true
|
||||
},
|
||||
// **optional** default: `[{ root: './' }]`
|
||||
// support monorepos
|
||||
projects: [
|
||||
'./vue', // shorthand for only root.
|
||||
{
|
||||
// **required**
|
||||
// Where is your project?
|
||||
// It is relative to `vetur.config.js`.
|
||||
root: './vue',
|
||||
// **optional** default: `'package.json'`
|
||||
// Where is `package.json` in the project?
|
||||
// We use it to determine the version of vue.
|
||||
// It is relative to root property.
|
||||
package: './vue/package.json',
|
||||
// **optional**
|
||||
// Where is TypeScript config file in the project?
|
||||
// It is relative to root property.
|
||||
tsconfig: './vue/tsconfig.json',
|
||||
// **optional** default: `'./.vscode/vetur/snippets'`
|
||||
// Where is vetur custom snippets folders?
|
||||
snippetFolder: './.vscode/vetur/snippets',
|
||||
// **optional** default: `[]`
|
||||
// Register globally Vue component glob.
|
||||
// If you set it, you can get completion by that components.
|
||||
// It is relative to root property.
|
||||
// Notice: It won't actually do it. You need to use `require.context` or `Vue.component`
|
||||
globalComponents: [
|
||||
'./vue/src/components/**/*.vue'
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -224,7 +224,7 @@ export default {
|
||||
this.refreshThis(thisItem.id)
|
||||
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_UPDATE)
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
console.log(err, err.response)
|
||||
StandardToasts.makeStandardToast(StandardToasts.FAIL_UPDATE)
|
||||
})
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
'new_value': function () {
|
||||
this.$root.$emit('change', this.field, this.new_value?.id ?? null)
|
||||
this.$root.$emit('change', this.field, this.new_value ?? null)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -1 +1,119 @@
|
||||
{"status":"done","chunks":{"recipe_search_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/recipe_search_view.js"],"recipe_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/recipe_view.js"],"offline_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/offline_view.js"],"import_response_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/import_response_view.js"],"supermarket_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/supermarket_view.js"],"user_file_view":["css/chunk-vendors.css","js/chunk-vendors.js","js/user_file_view.js"],"keyword_list_view":["css/chunk-vendors.css","js/chunk-vendors.js","css/keyword_list_view.css","js/keyword_list_view.js"],"food_list_view":["css/chunk-vendors.css","js/chunk-vendors.js","css/food_list_view.css","js/food_list_view.js"]},"assets":{"../../templates/sw.js":{"name":"../../templates/sw.js","path":"../../templates/sw.js"},"css/chunk-vendors.css":{"name":"css/chunk-vendors.css","path":"css/chunk-vendors.css"},"js/chunk-vendors.js":{"name":"js/chunk-vendors.js","path":"js/chunk-vendors.js"},"css/food_list_view.css":{"name":"css/food_list_view.css","path":"css/food_list_view.css"},"js/food_list_view.js":{"name":"js/food_list_view.js","path":"js/food_list_view.js"},"js/import_response_view.js":{"name":"js/import_response_view.js","path":"js/import_response_view.js"},"css/keyword_list_view.css":{"name":"css/keyword_list_view.css","path":"css/keyword_list_view.css"},"js/keyword_list_view.js":{"name":"js/keyword_list_view.js","path":"js/keyword_list_view.js"},"js/offline_view.js":{"name":"js/offline_view.js","path":"js/offline_view.js"},"js/recipe_search_view.js":{"name":"js/recipe_search_view.js","path":"js/recipe_search_view.js"},"js/recipe_view.js":{"name":"js/recipe_view.js","path":"js/recipe_view.js"},"js/supermarket_view.js":{"name":"js/supermarket_view.js","path":"js/supermarket_view.js"},"js/user_file_view.js":{"name":"js/user_file_view.js","path":"js/user_file_view.js"},"recipe_search_view.html":{"name":"recipe_search_view.html","path":"recipe_search_view.html"},"recipe_view.html":{"name":"recipe_view.html","path":"recipe_view.html"},"offline_view.html":{"name":"offline_view.html","path":"offline_view.html"},"import_response_view.html":{"name":"import_response_view.html","path":"import_response_view.html"},"supermarket_view.html":{"name":"supermarket_view.html","path":"supermarket_view.html"},"user_file_view.html":{"name":"user_file_view.html","path":"user_file_view.html"},"keyword_list_view.html":{"name":"keyword_list_view.html","path":"keyword_list_view.html"},"food_list_view.html":{"name":"food_list_view.html","path":"food_list_view.html"},"manifest.json":{"name":"manifest.json","path":"manifest.json"}}}
|
||||
{
|
||||
"status": "done",
|
||||
"assets": {
|
||||
"../../templates/sw.js": {
|
||||
"name": "../../templates/sw.js",
|
||||
"path": "..\\..\\templates\\sw.js"
|
||||
},
|
||||
"css/chunk-vendors.css": {
|
||||
"name": "css/chunk-vendors.css",
|
||||
"path": "css\\chunk-vendors.css"
|
||||
},
|
||||
"js/chunk-vendors.js": {
|
||||
"name": "js/chunk-vendors.js",
|
||||
"path": "js\\chunk-vendors.js"
|
||||
},
|
||||
"js/import_response_view.js": {
|
||||
"name": "js/import_response_view.js",
|
||||
"path": "js\\import_response_view.js"
|
||||
},
|
||||
"css/model_list_view.css": {
|
||||
"name": "css/model_list_view.css",
|
||||
"path": "css\\model_list_view.css"
|
||||
},
|
||||
"js/model_list_view.js": {
|
||||
"name": "js/model_list_view.js",
|
||||
"path": "js\\model_list_view.js"
|
||||
},
|
||||
"js/offline_view.js": {
|
||||
"name": "js/offline_view.js",
|
||||
"path": "js\\offline_view.js"
|
||||
},
|
||||
"js/recipe_search_view.js": {
|
||||
"name": "js/recipe_search_view.js",
|
||||
"path": "js\\recipe_search_view.js"
|
||||
},
|
||||
"js/recipe_view.js": {
|
||||
"name": "js/recipe_view.js",
|
||||
"path": "js\\recipe_view.js"
|
||||
},
|
||||
"js/supermarket_view.js": {
|
||||
"name": "js/supermarket_view.js",
|
||||
"path": "js\\supermarket_view.js"
|
||||
},
|
||||
"js/user_file_view.js": {
|
||||
"name": "js/user_file_view.js",
|
||||
"path": "js\\user_file_view.js"
|
||||
},
|
||||
"recipe_search_view.html": {
|
||||
"name": "recipe_search_view.html",
|
||||
"path": "recipe_search_view.html"
|
||||
},
|
||||
"recipe_view.html": {
|
||||
"name": "recipe_view.html",
|
||||
"path": "recipe_view.html"
|
||||
},
|
||||
"offline_view.html": {
|
||||
"name": "offline_view.html",
|
||||
"path": "offline_view.html"
|
||||
},
|
||||
"import_response_view.html": {
|
||||
"name": "import_response_view.html",
|
||||
"path": "import_response_view.html"
|
||||
},
|
||||
"supermarket_view.html": {
|
||||
"name": "supermarket_view.html",
|
||||
"path": "supermarket_view.html"
|
||||
},
|
||||
"user_file_view.html": {
|
||||
"name": "user_file_view.html",
|
||||
"path": "user_file_view.html"
|
||||
},
|
||||
"model_list_view.html": {
|
||||
"name": "model_list_view.html",
|
||||
"path": "model_list_view.html"
|
||||
},
|
||||
"manifest.json": {
|
||||
"name": "manifest.json",
|
||||
"path": "manifest.json"
|
||||
}
|
||||
},
|
||||
"chunks": {
|
||||
"recipe_search_view": [
|
||||
"css/chunk-vendors.css",
|
||||
"js/chunk-vendors.js",
|
||||
"js/recipe_search_view.js"
|
||||
],
|
||||
"recipe_view": [
|
||||
"css/chunk-vendors.css",
|
||||
"js/chunk-vendors.js",
|
||||
"js/recipe_view.js"
|
||||
],
|
||||
"offline_view": [
|
||||
"css/chunk-vendors.css",
|
||||
"js/chunk-vendors.js",
|
||||
"js/offline_view.js"
|
||||
],
|
||||
"import_response_view": [
|
||||
"css/chunk-vendors.css",
|
||||
"js/chunk-vendors.js",
|
||||
"js/import_response_view.js"
|
||||
],
|
||||
"supermarket_view": [
|
||||
"css/chunk-vendors.css",
|
||||
"js/chunk-vendors.js",
|
||||
"js/supermarket_view.js"
|
||||
],
|
||||
"user_file_view": [
|
||||
"css/chunk-vendors.css",
|
||||
"js/chunk-vendors.js",
|
||||
"js/user_file_view.js"
|
||||
],
|
||||
"model_list_view": [
|
||||
"css/chunk-vendors.css",
|
||||
"js/chunk-vendors.js",
|
||||
"css/model_list_view.css",
|
||||
"js/model_list_view.js"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user