/remote.php/webdav/ is added automatically)'), }
+
class ConnectorConfigForm(forms.ModelForm):
enabled = forms.BooleanField(
help_text="Is the connector enabled",
@@ -205,24 +206,6 @@ class ConnectorConfigForm(forms.ModelForm):
}
-# TODO: Deprecate
-# class RecipeBookEntryForm(forms.ModelForm):
-# prefix = 'bookmark'
-
-# def __init__(self, *args, **kwargs):
-# space = kwargs.pop('space')
-# super().__init__(*args, **kwargs)
-# self.fields['book'].queryset = RecipeBook.objects.filter(space=space).all()
-
-# class Meta:
-# model = RecipeBookEntry
-# fields = ('book',)
-
-# field_classes = {
-# 'book': SafeModelChoiceField,
-# }
-
-
class SyncForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
@@ -239,7 +222,6 @@ class SyncForm(forms.ModelForm):
labels = {'storage': _('Storage'), 'path': _('Path'), 'active': _('Active')}
-# TODO deprecate
class BatchEditForm(forms.Form):
search = forms.CharField(label=_('Search String'))
keywords = forms.ModelMultipleChoiceField(queryset=Keyword.objects.none(), required=False, widget=MultiSelectWidget)
@@ -373,73 +355,3 @@ class SearchPreferenceForm(forms.ModelForm):
'search': SelectWidget, 'unaccent': MultiSelectWidget, 'icontains': MultiSelectWidget, 'istartswith': MultiSelectWidget, 'trigram': MultiSelectWidget, 'fulltext':
MultiSelectWidget,
}
-
-
-# class ShoppingPreferenceForm(forms.ModelForm):
-# prefix = 'shopping'
-
-# class Meta:
-# model = UserPreference
-
-# fields = (
-# 'shopping_share', 'shopping_auto_sync', 'mealplan_autoadd_shopping', 'mealplan_autoexclude_onhand',
-# 'mealplan_autoinclude_related', 'shopping_add_onhand', 'default_delay', 'filter_to_supermarket', 'shopping_recent_days', 'csv_delim', 'csv_prefix'
-# )
-
-# help_texts = {
-# 'shopping_share': _('Users will see all items you add to your shopping list. They must add you to see items on their list.'),
-# 'shopping_auto_sync': _(
-# 'Setting to 0 will disable auto sync. When viewing a shopping list the list is updated every set seconds to sync changes someone else might have made. Useful when shopping with multiple people but might use a little bit '
-# 'of mobile data. If lower than instance limit it is reset when saving.'
-# ),
-# 'mealplan_autoadd_shopping': _('Automatically add meal plan ingredients to shopping list.'),
-# 'mealplan_autoinclude_related': _('When adding a meal plan to the shopping list (manually or automatically), include all related recipes.'),
-# 'mealplan_autoexclude_onhand': _('When adding a meal plan to the shopping list (manually or automatically), exclude ingredients that are on hand.'),
-# 'default_delay': _('Default number of hours to delay a shopping list entry.'),
-# 'filter_to_supermarket': _('Filter shopping list to only include supermarket categories.'),
-# 'shopping_recent_days': _('Days of recent shopping list entries to display.'),
-# 'shopping_add_onhand': _("Mark food 'On Hand' when checked off shopping list."),
-# 'csv_delim': _('Delimiter to use for CSV exports.'),
-# 'csv_prefix': _('Prefix to add when copying list to the clipboard.'),
-
-# }
-# labels = {
-# 'shopping_share': _('Share Shopping List'),
-# 'shopping_auto_sync': _('Autosync'),
-# 'mealplan_autoadd_shopping': _('Auto Add Meal Plan'),
-# 'mealplan_autoexclude_onhand': _('Exclude On Hand'),
-# 'mealplan_autoinclude_related': _('Include Related'),
-# 'default_delay': _('Default Delay Hours'),
-# 'filter_to_supermarket': _('Filter to Supermarket'),
-# 'shopping_recent_days': _('Recent Days'),
-# 'csv_delim': _('CSV Delimiter'),
-# "csv_prefix_label": _("List Prefix"),
-# 'shopping_add_onhand': _("Auto On Hand"),
-# }
-
-# widgets = {
-# 'shopping_share': MultiSelectWidget
-# }
-
-# class SpacePreferenceForm(forms.ModelForm):
-# prefix = 'space'
-# reset_food_inherit = forms.BooleanField(label=_("Reset Food Inheritance"), initial=False, required=False,
-# help_text=_("Reset all food to inherit the fields configured."))
-
-# def __init__(self, *args, **kwargs):
-# super().__init__(*args, **kwargs) # populates the post
-# self.fields['food_inherit'].queryset = Food.inheritable_fields
-
-# class Meta:
-# model = Space
-
-# fields = ('food_inherit', 'reset_food_inherit',)
-
-# help_texts = {
-# 'food_inherit': _('Fields on food that should be inherited by default.'),
-# 'use_plural': _('Use the plural form for units and food inside this space.'),
-# }
-
-# widgets = {
-# 'food_inherit': MultiSelectWidget
-# }
diff --git a/cookbook/helper/__init__.py b/cookbook/helper/__init__.py
index c1cb37885..7a7792027 100644
--- a/cookbook/helper/__init__.py
+++ b/cookbook/helper/__init__.py
@@ -1,6 +1,4 @@
-import cookbook.helper.dal
from cookbook.helper.AllAuthCustomAdapter import AllAuthCustomAdapter
__all__ = [
- 'dal',
]
diff --git a/cookbook/helper/dal.py b/cookbook/helper/dal.py
deleted file mode 100644
index 879279c88..000000000
--- a/cookbook/helper/dal.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from cookbook.models import Food, Keyword, Recipe, Unit
-
-from dal import autocomplete
-
-
-class BaseAutocomplete(autocomplete.Select2QuerySetView):
- model = None
-
- def get_queryset(self):
- if not self.request.user.is_authenticated:
- return self.model.objects.none()
-
- qs = self.model.objects.filter(space=self.request.space).all()
-
- if self.q:
- qs = qs.filter(name__icontains=self.q)
-
- return qs
-
-
-class KeywordAutocomplete(BaseAutocomplete):
- model = Keyword
-
-
-class IngredientsAutocomplete(BaseAutocomplete):
- model = Food
-
-
-class RecipeAutocomplete(BaseAutocomplete):
- model = Recipe
-
-
-class UnitAutocomplete(BaseAutocomplete):
- model = Unit
diff --git a/cookbook/helper/permission_helper.py b/cookbook/helper/permission_helper.py
index 889d75055..b6e49771f 100644
--- a/cookbook/helper/permission_helper.py
+++ b/cookbook/helper/permission_helper.py
@@ -75,7 +75,7 @@ def is_object_owner(user, obj):
if not user.is_authenticated:
return False
try:
- return obj.get_owner() == user
+ return obj.get_owner() == 'orphan' or obj.get_owner() == user
except Exception:
return False
diff --git a/cookbook/helper/shopping_helper.py b/cookbook/helper/shopping_helper.py
index c7772a078..c4c5659b2 100644
--- a/cookbook/helper/shopping_helper.py
+++ b/cookbook/helper/shopping_helper.py
@@ -1,9 +1,8 @@
-from datetime import timedelta
+
from decimal import Decimal
from django.db.models import F, OuterRef, Q, Subquery, Value
from django.db.models.functions import Coalesce
-from django.utils import timezone
from django.utils.translation import gettext as _
from cookbook.models import (Ingredient, MealPlan, Recipe, ShoppingListEntry, ShoppingListRecipe,
@@ -76,10 +75,8 @@ class RecipeShoppingEditor():
@staticmethod
def get_shopping_list_recipe(id, user, space):
- return ShoppingListRecipe.objects.filter(id=id).filter(Q(shoppinglist__space=space) | Q(entries__space=space)).filter(
- Q(shoppinglist__created_by=user)
- | Q(shoppinglist__shared=user)
- | Q(entries__created_by=user)
+ return ShoppingListRecipe.objects.filter(id=id).filter(entries__space=space).filter(
+ Q(entries__created_by=user)
| Q(entries__created_by__in=list(user.get_shopping_share()))
).prefetch_related('entries').first()
diff --git a/cookbook/locale/sv/LC_MESSAGES/django.po b/cookbook/locale/sv/LC_MESSAGES/django.po
index 5137fb7eb..6fec1dc0e 100644
--- a/cookbook/locale/sv/LC_MESSAGES/django.po
+++ b/cookbook/locale/sv/LC_MESSAGES/django.po
@@ -8,8 +8,8 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-04-11 15:09+0200\n"
-"PO-Revision-Date: 2022-04-17 00:31+0000\n"
-"Last-Translator: Oskar Stenberg <01ste02@gmail.com>\n"
+"PO-Revision-Date: 2024-02-27 12:19+0000\n"
+"Last-Translator: Lukas Åteg