From c6f40db7e398d92fe1bc401abc61c8e7399a8943 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 20 Oct 2020 20:54:15 +0200 Subject: [PATCH] shopping list tweaks --- cookbook/filters.py | 7 +++++++ cookbook/templates/shopping_list.html | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cookbook/filters.py b/cookbook/filters.py index 6d0894d58..88e4c94b7 100644 --- a/cookbook/filters.py +++ b/cookbook/filters.py @@ -55,6 +55,13 @@ class IngredientFilter(django_filters.FilterSet): class ShoppingListFilter(django_filters.FilterSet): + + def __init__(self, data=None, *args, **kwargs): + if data is not None: + data = data.copy() + data.setdefault("finished", False) + super(ShoppingListFilter, self).__init__(data, *args, **kwargs) + class Meta: model = ShoppingList fields = ['finished'] diff --git a/cookbook/templates/shopping_list.html b/cookbook/templates/shopping_list.html index c7f114c86..c5817c6d4 100644 --- a/cookbook/templates/shopping_list.html +++ b/cookbook/templates/shopping_list.html @@ -452,7 +452,9 @@ } } } - + if (this.shopping_list.entries.length === 0) { + this.edit_mode = true + } }).catch((err) => { console.log(err) this.makeToast('{% trans 'Error' %}', '{% trans 'There was an error loading a resource!' %}' + err.bodyText, 'danger') @@ -463,11 +465,15 @@ "entries": [], "entries_display": [], "shared": [{% for u in request.user.userpreference.plan_share.all %} - { 'id': {{ u.pk }}, 'username': '{{ u.get_user_name }}' }, + {'id': {{ u.pk }}, 'username': '{{ u.get_user_name }}'}, {% endfor %}], "created_by": 1 } this.loading = false + + if (this.shopping_list.entries.length === 0) { + this.edit_mode = true + } } }, updateShoppingList: function () {