ingredient linking fixed + tests fixed

This commit is contained in:
vabene1111 2021-01-19 21:26:20 +01:00
parent 523a2b41d1
commit b563447674
5 changed files with 36 additions and 29 deletions

View File

@ -139,7 +139,7 @@ def find_recipe_json(ld_json, url):
if k := Keyword.objects.filter(name=kw).first():
keywords.append({'id': str(k.id), 'text': str(k).strip()})
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
else:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -10,14 +10,14 @@ class TestEditsRecipe(TestBase):
# flake8: noqa
def test_ld_json(self):
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_3.html', 'result_length': 1629},
{'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/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_4.html', 'result_length': 4396},
]

View File

@ -1,35 +1,39 @@
<template>
<tr @click="$emit('checked-state-changed', ingredient)">
<td>
<i class="far fa-check-circle text-success" v-if="ingredient.checked"></i>
<i class="far fa-check-circle text-primary" v-if="!ingredient.checked"></i>
</td>
<td>
<span v-if="ingredient.amount !== 0">{{ calculateAmount(ingredient.amount) }}</span>
</td>
<td>
<span v-if="ingredient.unit !== null">{{ ingredient.unit.name }}</span>
</td>
<td>
<span v-if="ingredient.food !== null">{{ ingredient.food.name }}</span>
</td>
<td>
<div v-if="ingredient.note">
<tr @click="$emit('checked-state-changed', ingredient)">
<td>
<i class="far fa-check-circle text-success" v-if="ingredient.checked"></i>
<i class="far fa-check-circle text-primary" v-if="!ingredient.checked"></i>
</td>
<td>
<span v-if="ingredient.amount !== 0">{{ calculateAmount(ingredient.amount) }}</span>
</td>
<td>
<span v-if="ingredient.unit !== null">{{ ingredient.unit.name }}</span>
</td>
<td>
<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>
<div v-if="ingredient.note">
<span v-b-popover.hover="ingredient.note"
class="d-print-none"> <i class="far fa-comment"></i>
class="d-print-none"> <i class="far fa-comment"></i>
</span>
<div class="d-none d-print-block">
<i class="far fa-comment-alt"></i> {{ ingredient.note }}
</div>
<div class="d-none d-print-block">
<i class="far fa-comment-alt"></i> {{ ingredient.note }}
</div>
</td>
</tr>
</div>
</td>
</tr>
</template>
<script>
import {calculateAmount} from "@/utils/utils";
import {calculateAmount, ResolveUrlMixin} from "@/utils/utils";
export default {
name: 'Ingredient',
@ -40,6 +44,9 @@ export default {
default: 1,
}
},
mixins: [
ResolveUrlMixin
],
data() {
return {
checked: false