search view fixes/updates
This commit is contained in:
parent
0a99791021
commit
aafbc497cc
@ -1,3 +1,4 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from django.contrib.postgres.search import TrigramSimilarity
|
from django.contrib.postgres.search import TrigramSimilarity
|
||||||
@ -22,10 +23,9 @@ def search_recipes(request, queryset, params):
|
|||||||
search_last_viewed = int(params.get('last_viewed', 0))
|
search_last_viewed = int(params.get('last_viewed', 0))
|
||||||
|
|
||||||
if search_last_viewed > 0:
|
if search_last_viewed > 0:
|
||||||
last_viewed_recipes = ViewLog.objects.filter(created_by=request.user, space=request.space).values_list('recipe__pk', flat=True).distinct()
|
last_viewed_recipes = ViewLog.objects.filter(created_by=request.user, space=request.space, created_at__gte=datetime.now() - timedelta(days=14)).values_list('recipe__pk', flat=True).distinct()
|
||||||
# TODO filter by created by in last two weeks and re add limit to recipe selection (after reversing the order)
|
|
||||||
# Distinct does not work with order by
|
return queryset.filter(pk__in=list(set(last_viewed_recipes))[-search_last_viewed:])
|
||||||
return queryset.filter(pk__in=list(set(last_viewed_recipes)))
|
|
||||||
|
|
||||||
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
|
if settings.DATABASES['default']['ENGINE'] in ['django.db.backends.postgresql_psycopg2',
|
||||||
'django.db.backends.postgresql']:
|
'django.db.backends.postgresql']:
|
||||||
|
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
@ -42,16 +42,22 @@
|
|||||||
{{ $t('Reset_Search') }}
|
{{ $t('Reset_Search') }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3" style="position: relative; margin-top: 1vh">
|
<div class="col-md-2" style="position: relative; margin-top: 1vh">
|
||||||
<b-form-checkbox v-model="search_internal" name="check-button" @change="refreshData"
|
<b-form-checkbox v-model="search_internal" name="check-button" @change="refreshData"
|
||||||
class="shadow-none"
|
class="shadow-none"
|
||||||
style="position:relative;top: 50%; transform: translateY(-50%);" switch>
|
style="position:relative;top: 50%; transform: translateY(-50%);" switch>
|
||||||
{{ $t('show_only_internal') }}
|
{{ $t('show_only_internal') }}
|
||||||
</b-form-checkbox>
|
</b-form-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-1" style="position: relative; margin-top: 1vh">
|
||||||
|
<button id="id_settings_button" class="btn btn-primary btn-block"><i class="fas fa-cog"></i></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button id="id_settings_button" class="btn btn-primary"><i class="fas fa-cog"></i></button>
|
|
||||||
<b-popover
|
<b-popover
|
||||||
target="id_settings_button"
|
target="id_settings_button"
|
||||||
triggers="click"
|
triggers="click"
|
||||||
@ -61,8 +67,8 @@
|
|||||||
<b-form-group
|
<b-form-group
|
||||||
v-bind:label="$t('Recently_Viewed')"
|
v-bind:label="$t('Recently_Viewed')"
|
||||||
label-for="popover-input-1"
|
label-for="popover-input-1"
|
||||||
label-cols="3"
|
label-cols="6"
|
||||||
class="mb-1">
|
class="mb-3">
|
||||||
<b-form-input
|
<b-form-input
|
||||||
type="number"
|
type="number"
|
||||||
v-model="settings.recently_viewed"
|
v-model="settings.recently_viewed"
|
||||||
@ -70,11 +76,12 @@
|
|||||||
size="sm"
|
size="sm"
|
||||||
></b-form-input>
|
></b-form-input>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group
|
<b-form-group
|
||||||
v-bind:label="$t('Meal_Plan')"
|
v-bind:label="$t('Meal_Plan')"
|
||||||
label-for="popover-input-2"
|
label-for="popover-input-2"
|
||||||
label-cols="3"
|
label-cols="6"
|
||||||
class="mb-1">
|
class="mb-3">
|
||||||
<b-form-checkbox
|
<b-form-checkbox
|
||||||
switch
|
switch
|
||||||
v-model="settings.show_meal_plan"
|
v-model="settings.show_meal_plan"
|
||||||
@ -85,9 +92,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row" style="margin-top: 1vh">
|
<div class="row" style="margin-top: 1vh">
|
||||||
<div class="col-12" style="text-align: right">
|
<div class="col-12" style="text-align: right">
|
||||||
<b-button size="sm" variant="secondary" style="margin-right:8px">Cancel
|
<b-button size="sm" variant="secondary" style="margin-right:8px" @click="$root.$emit('bv::hide::popover')">{{$t('Close')}}</b-button>
|
||||||
</b-button>
|
|
||||||
<b-button size="sm" variant="primary">Ok</b-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</b-popover>
|
</b-popover>
|
||||||
|
Loading…
Reference in New Issue
Block a user