ingredient linking fixed + tests fixed
This commit is contained in:
parent
523a2b41d1
commit
b563447674
@ -139,7 +139,7 @@ def find_recipe_json(ld_json, url):
|
|||||||
if k := Keyword.objects.filter(name=kw).first():
|
if k := Keyword.objects.filter(name=kw).first():
|
||||||
keywords.append({'id': str(k.id), 'text': str(k).strip()})
|
keywords.append({'id': str(k.id), 'text': str(k).strip()})
|
||||||
else:
|
else:
|
||||||
keywords.append({'id': random.randrange(0, 9999999, 1), 'text': kw.strip()})
|
keywords.append({'id': random.randrange(1111111, 9999999, 1), 'text': kw.strip()})
|
||||||
|
|
||||||
ld_json['keywords'] = keywords
|
ld_json['keywords'] = keywords
|
||||||
else:
|
else:
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -10,14 +10,14 @@ class TestEditsRecipe(TestBase):
|
|||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
def test_ld_json(self):
|
def test_ld_json(self):
|
||||||
test_list = [
|
test_list = [
|
||||||
{'file': 'cookbook/tests/resources/websites/ld_json_1.html', 'result_length': 3218},
|
{'file': 'cookbook/tests/resources/websites/ld_json_1.html', 'result_length': 3222},
|
||||||
{'file': 'cookbook/tests/resources/websites/ld_json_2.html', 'result_length': 1510},
|
{'file': 'cookbook/tests/resources/websites/ld_json_2.html', 'result_length': 1510},
|
||||||
{'file': 'cookbook/tests/resources/websites/ld_json_3.html', 'result_length': 1629},
|
{'file': 'cookbook/tests/resources/websites/ld_json_3.html', 'result_length': 1629},
|
||||||
{'file': 'cookbook/tests/resources/websites/ld_json_4.html', 'result_length': 1729},
|
{'file': 'cookbook/tests/resources/websites/ld_json_4.html', 'result_length': 1729},
|
||||||
{'file': 'cookbook/tests/resources/websites/ld_json_itemList.html', 'result_length': 3200},
|
{'file': 'cookbook/tests/resources/websites/ld_json_itemList.html', 'result_length': 3206},
|
||||||
{'file': 'cookbook/tests/resources/websites/ld_json_multiple.html', 'result_length': 1606},
|
{'file': 'cookbook/tests/resources/websites/ld_json_multiple.html', 'result_length': 1606},
|
||||||
{'file': 'cookbook/tests/resources/websites/micro_data_1.html', 'result_length': 1079},
|
{'file': 'cookbook/tests/resources/websites/micro_data_1.html', 'result_length': 1079},
|
||||||
{'file': 'cookbook/tests/resources/websites/micro_data_2.html', 'result_length': 1429},
|
{'file': 'cookbook/tests/resources/websites/micro_data_2.html', 'result_length': 1438},
|
||||||
{'file': 'cookbook/tests/resources/websites/micro_data_3.html', 'result_length': 1148},
|
{'file': 'cookbook/tests/resources/websites/micro_data_3.html', 'result_length': 1148},
|
||||||
{'file': 'cookbook/tests/resources/websites/micro_data_4.html', 'result_length': 4396},
|
{'file': 'cookbook/tests/resources/websites/micro_data_4.html', 'result_length': 4396},
|
||||||
]
|
]
|
||||||
|
@ -11,7 +11,11 @@
|
|||||||
<span v-if="ingredient.unit !== null">{{ ingredient.unit.name }}</span>
|
<span v-if="ingredient.unit !== null">{{ ingredient.unit.name }}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span v-if="ingredient.food !== null">{{ ingredient.food.name }}</span>
|
<template v-if="ingredient.food !== null">
|
||||||
|
<a :href="resolveDjangoUrl('view_recipe', ingredient.food.recipe)" v-if="ingredient.food.recipe !== null"
|
||||||
|
target="_blank" rel="noopener noreferrer">{{ ingredient.food.name }}</a>
|
||||||
|
<span v-if="ingredient.food.recipe === null">{{ ingredient.food.name }}</span>
|
||||||
|
</template>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div v-if="ingredient.note">
|
<div v-if="ingredient.note">
|
||||||
@ -29,7 +33,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import {calculateAmount} from "@/utils/utils";
|
import {calculateAmount, ResolveUrlMixin} from "@/utils/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Ingredient',
|
name: 'Ingredient',
|
||||||
@ -40,6 +44,9 @@ export default {
|
|||||||
default: 1,
|
default: 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mixins: [
|
||||||
|
ResolveUrlMixin
|
||||||
|
],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
checked: false
|
checked: false
|
||||||
|
Loading…
Reference in New Issue
Block a user