mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-23 18:29:23 -05:00
quick optimizations
This commit is contained in:
@@ -190,7 +190,12 @@ class SpaceFilterSerializer(serializers.ListSerializer):
|
||||
iterable = data.all() if hasattr(data, 'all') else data
|
||||
if isinstance(iterable, list) or (isinstance(iterable, QuerySet) and getattr(iterable, '_result_cache', None) is not None):
|
||||
try:
|
||||
data = [d for d in iterable if d.userspace.space.id == self.context['request'].space.id]
|
||||
new_data = []
|
||||
for u in iterable:
|
||||
for us in u.userspace_set.all():
|
||||
if us.space.id == self.context['request'].space.id:
|
||||
new_data.append(u)
|
||||
data = new_data
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
data = data.filter(userspace__space=self.context['request'].user.get_active_space()).all()
|
||||
|
||||
@@ -2044,10 +2044,12 @@ class ShoppingListEntryViewSet(LoggingMixin, viewsets.ModelViewSet):
|
||||
def get_queryset(self):
|
||||
self.queryset = self.queryset.filter(space=self.request.space)
|
||||
|
||||
# select_related("list_recipe")
|
||||
self.queryset = self.queryset.filter(
|
||||
Q(created_by=self.request.user)
|
||||
| Q(created_by__in=list(self.request.user.get_shopping_share()))).prefetch_related('created_by',
|
||||
'food',
|
||||
'food__shopping_lists',
|
||||
'shopping_lists',
|
||||
'unit',
|
||||
'list_recipe',
|
||||
@@ -2055,9 +2057,7 @@ class ShoppingListEntryViewSet(LoggingMixin, viewsets.ModelViewSet):
|
||||
'list_recipe__recipe__created_by',
|
||||
'list_recipe__mealplan',
|
||||
'list_recipe__mealplan__shared',
|
||||
|
||||
'list_recipe__mealplan__shared__userpreference',
|
||||
'list_recipe__mealplan__shared__userpreference__space',
|
||||
'list_recipe__mealplan__shared__userspace_set',
|
||||
'list_recipe__mealplan__shoppinglistrecipe_set',
|
||||
'list_recipe__mealplan__recipe',
|
||||
'list_recipe__mealplan__recipe__keywords',
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<template v-slot:[selectBtnSlot]="{ isSelected, select }">
|
||||
<template v-slot:[selectBtnSlot]="{ isSelected, select }" v-if="selectEnabled">
|
||||
<v-list-item-action class="ps-3 pe-3" start>
|
||||
<v-checkbox-btn :model-value="isSelected" @update:model-value="select" @click.native.stop=""></v-checkbox-btn>
|
||||
</v-list-item-action>
|
||||
@@ -79,12 +79,12 @@ const emit = defineEmits(['clicked'])
|
||||
|
||||
const props = defineProps({
|
||||
shoppingListFood: {type: {} as PropType<IShoppingListFood>, required: true},
|
||||
hideInfoRow: {type: Boolean, default: false}
|
||||
hideInfoRow: {type: Boolean, default: false},
|
||||
selectEnabled: {type: Boolean, default: false}
|
||||
})
|
||||
const checkBtnSlot = ref(useUserPreferenceStore().userSettings.leftHanded ? 'prepend' : 'append')
|
||||
const selectBtnSlot = ref(useUserPreferenceStore().userSettings.leftHanded ? 'append' : 'prepend')
|
||||
|
||||
const selectEnabled = ref(true)
|
||||
const dialog = ref(false)
|
||||
|
||||
const entries = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user