Merge pull request #1143 from smilerz/fix_get_facet_api

fix bug in get_facet_api
This commit is contained in:
vabene1111 2021-12-16 18:10:48 +01:00 committed by GitHub
commit aaaae5b1ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 91 additions and 142 deletions

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,7 @@ from cookbook.helper.permission_helper import (CustomIsAdmin, CustomIsGuest, Cus
CustomIsShare, CustomIsShared, CustomIsUser,
group_required)
from cookbook.helper.recipe_html_import import get_recipe_from_source
from cookbook.helper.recipe_search import get_facet, search_recipes, old_search
from cookbook.helper.recipe_search import get_facet, old_search, search_recipes
from cookbook.helper.recipe_url_import import get_from_scraper
from cookbook.models import (Automation, BookmarkletImport, CookLog, Food, ImportLog, Ingredient,
Keyword, MealPlan, MealType, Recipe, RecipeBook, RecipeBookEntry,
@ -46,9 +46,7 @@ from cookbook.models import (Automation, BookmarkletImport, CookLog, Food, Impor
from cookbook.provider.dropbox import Dropbox
from cookbook.provider.local import Local
from cookbook.provider.nextcloud import Nextcloud
from cookbook.schemas import FilterSchema, TreeSchema, QueryParamAutoSchema, QueryParam
from cookbook.schemas import FilterSchema, QueryParam, QueryParamAutoSchema, TreeSchema
from cookbook.serializer import (AutomationSerializer, BookmarkletImportSerializer,
CookLogSerializer, FoodSerializer, ImportLogSerializer,
IngredientSerializer, KeywordSerializer, MealPlanSerializer,
@ -985,7 +983,7 @@ def ingredient_from_string(request):
@group_required('user')
def get_facets(request):
key = request.GET['hash']
key = request.GET.get('hash', None)
return JsonResponse(
{

View File

@ -7,24 +7,15 @@
<div class="row justify-content-center">
<div class="col-12 col-lg-10 col-xl-8 mt-3 mb-3">
<b-input-group>
<b-input
class="form-control form-control-lg form-control-borderless form-control-search"
v-model="settings.search_input"
v-bind:placeholder="$t('Search')"
></b-input>
<b-input class="form-control form-control-lg form-control-borderless form-control-search" v-model="settings.search_input" v-bind:placeholder="$t('Search')"></b-input>
<b-input-group-append>
<b-button v-b-tooltip.hover :title="$t('show_sql')" @click="showSQL()">
<b-button v-b-tooltip.hover :title="$t('show_sql')" @click="showSQL()" v-if="debug">
<i class="fas fa-bug" style="font-size: 1.5em"></i>
</b-button>
<b-button variant="light" v-b-tooltip.hover :title="$t('Random Recipes')" @click="openRandom()">
<i class="fas fa-dice-five" style="font-size: 1.5em"></i>
</b-button>
<b-button
v-b-toggle.collapse_advanced_search
v-b-tooltip.hover
:title="$t('Advanced Settings')"
v-bind:variant="!isAdvancedSettingsSet() ? 'primary' : 'danger'"
>
<b-button v-b-toggle.collapse_advanced_search v-b-tooltip.hover :title="$t('Advanced Settings')" v-bind:variant="!isAdvancedSettingsSet() ? 'primary' : 'danger'">
<!-- TODO consider changing this icon to a filter -->
<i class="fas fa-caret-down" v-if="!settings.advanced_search_visible"></i>
<i class="fas fa-caret-up" v-if="settings.advanced_search_visible"></i>
@ -78,13 +69,7 @@
<b-form-checkbox switch v-model="settings.show_meal_plan" id="popover-input-2" size="sm"></b-form-checkbox>
</b-form-group>
<b-form-group
v-if="settings.show_meal_plan"
v-bind:label="$t('Meal_Plan_Days')"
label-for="popover-input-5"
label-cols="6"
class="mb-3"
>
<b-form-group v-if="settings.show_meal_plan" v-bind:label="$t('Meal_Plan_Days')" label-for="popover-input-5" label-cols="6" class="mb-3">
<b-form-input type="number" v-model="settings.meal_plan_days" id="popover-input-5" size="sm"></b-form-input>
</b-form-group>
@ -99,9 +84,7 @@
</div>
<div class="row" style="margin-top: 1vh">
<div class="col-12" style="text-align: right">
<b-button size="sm" variant="secondary" style="margin-right: 8px" @click="$root.$emit('bv::hide::popover')"
>{{ $t("Close") }}
</b-button>
<b-button size="sm" variant="secondary" style="margin-right: 8px" @click="$root.$emit('bv::hide::popover')">{{ $t("Close") }} </b-button>
</div>
</div>
</b-popover>
@ -123,13 +106,7 @@
/>
<b-input-group-append>
<b-input-group-text>
<b-form-checkbox
v-model="settings.search_keywords_or"
name="check-button"
@change="refreshData(false)"
class="shadow-none"
switch
>
<b-form-checkbox v-model="settings.search_keywords_or" name="check-button" @change="refreshData(false)" class="shadow-none" switch>
<span class="text-uppercase" v-if="settings.search_keywords_or">{{ $t("or") }}</span>
<span class="text-uppercase" v-else>{{ $t("and") }}</span>
</b-form-checkbox>
@ -156,13 +133,7 @@
/>
<b-input-group-append>
<b-input-group-text>
<b-form-checkbox
v-model="settings.search_foods_or"
name="check-button"
@change="refreshData(false)"
class="shadow-none"
switch
>
<b-form-checkbox v-model="settings.search_foods_or" name="check-button" @change="refreshData(false)" class="shadow-none" switch>
<span class="text-uppercase" v-if="settings.search_foods_or">{{ $t("or") }}</span>
<span class="text-uppercase" v-else>{{ $t("and") }}</span>
</b-form-checkbox>
@ -187,14 +158,7 @@
></generic-multiselect>
<b-input-group-append>
<b-input-group-text>
<b-form-checkbox
v-model="settings.search_books_or"
name="check-button"
@change="refreshData(false)"
class="shadow-none"
tyle="width: 100%"
switch
>
<b-form-checkbox v-model="settings.search_books_or" name="check-button" @change="refreshData(false)" class="shadow-none" tyle="width: 100%" switch>
<span class="text-uppercase" v-if="settings.search_books_or">{{ $t("or") }}</span>
<span class="text-uppercase" v-else>{{ $t("and") }}</span>
</b-form-checkbox>
@ -242,14 +206,7 @@
<div class="col col-md-12">
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); grid-gap: 0.8rem">
<template v-if="!searchFiltered">
<recipe-card
v-bind:key="`mp_${m.id}`"
v-for="m in meal_plans"
:recipe="m.recipe"
:meal_plan="m"
:footer_text="m.meal_type_name"
footer_icon="far fa-calendar-alt"
></recipe-card>
<recipe-card v-bind:key="`mp_${m.id}`" v-for="m in meal_plans" :recipe="m.recipe" :meal_plan="m" :footer_text="m.meal_type_name" footer_icon="far fa-calendar-alt"></recipe-card>
</template>
<recipe-card v-for="r in recipes" v-bind:key="r.id" :recipe="r" :footer_text="isRecentOrNew(r)[0]" :footer_icon="isRecentOrNew(r)[1]"> </recipe-card>
</div>
@ -258,8 +215,7 @@
<div class="row" style="margin-top: 2vh" v-if="!random_search">
<div class="col col-md-12">
<b-pagination pills v-model="settings.pagination_page" :total-rows="pagination_count" :per-page="settings.page_count" @change="pageChange" align="center">
</b-pagination>
<b-pagination pills v-model="settings.pagination_page" :total-rows="pagination_count" :per-page="settings.page_count" @change="pageChange" align="center"> </b-pagination>
</div>
</div>
</div>
@ -389,7 +345,7 @@ export default {
this.refreshData(false)
})
this.$i18n.locale = window.CUSTOM_LOCALE
this.debug = localStorage.getItem("DEBUG") || false
this.debug = localStorage.getItem("DEBUG") == "True" || false
},
watch: {
settings: {

View File

@ -1,45 +1,45 @@
const BundleTracker = require("webpack-bundle-tracker");
const BundleTracker = require("webpack-bundle-tracker")
const pages = {
'recipe_search_view': {
entry: './src/apps/RecipeSearchView/main.js',
chunks: ['chunk-vendors']
recipe_search_view: {
entry: "./src/apps/RecipeSearchView/main.js",
chunks: ["chunk-vendors"],
},
'recipe_view': {
entry: './src/apps/RecipeView/main.js',
chunks: ['chunk-vendors']
recipe_view: {
entry: "./src/apps/RecipeView/main.js",
chunks: ["chunk-vendors"],
},
'offline_view': {
entry: './src/apps/OfflineView/main.js',
chunks: ['chunk-vendors']
offline_view: {
entry: "./src/apps/OfflineView/main.js",
chunks: ["chunk-vendors"],
},
'import_response_view': {
entry: './src/apps/ImportResponseView/main.js',
chunks: ['chunk-vendors']
import_response_view: {
entry: "./src/apps/ImportResponseView/main.js",
chunks: ["chunk-vendors"],
},
'supermarket_view': {
entry: './src/apps/SupermarketView/main.js',
chunks: ['chunk-vendors']
supermarket_view: {
entry: "./src/apps/SupermarketView/main.js",
chunks: ["chunk-vendors"],
},
'model_list_view': {
entry: './src/apps/ModelListView/main.js',
chunks: ['chunk-vendors']
model_list_view: {
entry: "./src/apps/ModelListView/main.js",
chunks: ["chunk-vendors"],
},
'edit_internal_recipe': {
entry: './src/apps/RecipeEditView/main.js',
chunks: ['chunk-vendors']
edit_internal_recipe: {
entry: "./src/apps/RecipeEditView/main.js",
chunks: ["chunk-vendors"],
},
'cookbook_view': {
entry: './src/apps/CookbookView/main.js',
chunks: ['chunk-vendors']
cookbook_view: {
entry: "./src/apps/CookbookView/main.js",
chunks: ["chunk-vendors"],
},
'meal_plan_view': {
entry: './src/apps/MealPlanView/main.js',
chunks: ['chunk-vendors']
meal_plan_view: {
entry: "./src/apps/MealPlanView/main.js",
chunks: ["chunk-vendors"],
},
'checklist_view': {
entry: './src/apps/ChecklistView/main.js',
chunks: ['chunk-vendors']
checklist_view: {
entry: "./src/apps/ChecklistView/main.js",
chunks: ["chunk-vendors"],
},
}
@ -47,54 +47,51 @@ module.exports = {
pages: pages,
filenameHashing: false,
productionSourceMap: false,
publicPath: process.env.NODE_ENV === 'production'
? ''
: 'http://localhost:8080/',
outputDir: '../cookbook/static/vue/',
publicPath: process.env.NODE_ENV === "production" ? "" : "http://localhost:8080/",
outputDir: "../cookbook/static/vue/",
runtimeCompiler: true,
pwa: {
name: 'Recipes',
themeColor: '#4DBA87',
msTileColor: '#000000',
appleMobileWebAppCapable: 'yes',
appleMobileWebAppStatusBarStyle: 'black',
name: "Recipes",
themeColor: "#4DBA87",
msTileColor: "#000000",
appleMobileWebAppCapable: "yes",
appleMobileWebAppStatusBarStyle: "black",
workboxPluginMode: 'InjectManifest',
workboxPluginMode: "InjectManifest",
workboxOptions: {
swSrc: './src/sw.js',
swDest: '../../templates/sw.js',
swSrc: "./src/sw.js",
swDest: "../../templates/sw.js",
manifestTransforms: [
originalManifest => {
const result = originalManifest.map(entry => new Object({url: 'static/vue/' + entry.url}))
return {manifest: result, warnings: []};
}
(originalManifest) => {
const result = originalManifest.map((entry) => new Object({ url: "static/vue/" + entry.url }))
return { manifest: result, warnings: [] }
},
],
}
},
},
pluginOptions: {
i18n: {
locale: 'en',
fallbackLocale: 'en',
localeDir: 'locales',
enableInSFC: true
}
locale: "en",
fallbackLocale: "en",
localeDir: "locales",
enableInSFC: true,
},
},
chainWebpack: config => {
config.optimization.splitChunks({
chainWebpack: (config) => {
config.optimization.splitChunks(
{
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "chunk-vendors",
chunks: "all",
priority: 1
priority: 1,
},
},
},
// TODO make this conditional on .env DEBUG = FALSE
config.optimization.minimize(true)
);
)
//TODO somehow remov them as they are also added to the manifest config of the service worker
/*
@ -105,19 +102,17 @@ module.exports = {
})
*/
config.plugin('BundleTracker').use(BundleTracker, [{relativePath: true, path: '../vue/'}]);
config.plugin("BundleTracker").use(BundleTracker, [{ relativePath: true, path: "../vue/" }])
config.resolve.alias
.set('__STATIC__', 'static')
config.resolve.alias.set("__STATIC__", "static")
config.devServer
.public('http://localhost:8080')
.host('localhost')
.public("http://localhost:8080")
.host("localhost")
.port(8080)
.hotOnly(true)
.watchOptions({poll: 500})
.watchOptions({ poll: 500 })
.https(false)
.headers({"Access-Control-Allow-Origin": ["*"]})
}
};
.headers({ "Access-Control-Allow-Origin": ["*"] })
},
}