diff --git a/cookbook/filters.py b/cookbook/filters.py index 916435009..6d0894d58 100644 --- a/cookbook/filters.py +++ b/cookbook/filters.py @@ -2,7 +2,7 @@ import django_filters from django.contrib.postgres.search import TrigramSimilarity from django.db.models import Q from cookbook.forms import MultiSelectWidget -from cookbook.models import Recipe, Keyword, Food +from cookbook.models import Recipe, Keyword, Food, ShoppingList from django.conf import settings from django.utils.translation import gettext as _ @@ -52,3 +52,9 @@ class IngredientFilter(django_filters.FilterSet): class Meta: model = Food fields = ['name'] + + +class ShoppingListFilter(django_filters.FilterSet): + class Meta: + model = ShoppingList + fields = ['finished'] diff --git a/cookbook/migrations/0089_shoppinglist_finished.py b/cookbook/migrations/0089_shoppinglist_finished.py new file mode 100644 index 000000000..3bad27b2e --- /dev/null +++ b/cookbook/migrations/0089_shoppinglist_finished.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-09-29 11:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0088_auto_20200929_1202'), + ] + + operations = [ + migrations.AddField( + model_name='shoppinglist', + name='finished', + field=models.BooleanField(default=False), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 06d858a22..2f1309e10 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -312,6 +312,7 @@ class ShoppingList(models.Model): recipes = models.ManyToManyField(ShoppingListRecipe, blank=True) entries = models.ManyToManyField(ShoppingListEntry, blank=True) shared = models.ManyToManyField(User, blank=True, related_name='list_share') + finished = models.BooleanField(default=False) created_by = models.ForeignKey(User, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index b59653e23..d37c145d4 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -234,7 +234,7 @@ class ShoppingListSerializer(WritableNestedModelSerializer): class Meta: model = ShoppingList - fields = ('id', 'uuid', 'note', 'recipes', 'entries', 'shared', 'created_by', 'created_at',) + fields = ('id', 'uuid', 'note', 'recipes', 'entries', 'shared', 'finished', 'created_by', 'created_at',) read_only_fields = ('id',) diff --git a/cookbook/tables.py b/cookbook/tables.py index e5c99cd9b..a29a75366 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -114,7 +114,7 @@ class ShoppingListTable(tables.Table): class Meta: model = ShoppingList template_name = 'generic/table_template.html' - fields = ('id', 'created_by', 'created_at') + fields = ('id', 'finished', 'created_by', 'created_at') class InviteLinkTable(tables.Table): diff --git a/cookbook/templates/generic/list_template.html b/cookbook/templates/generic/list_template.html index b330ef326..bd69e5260 100644 --- a/cookbook/templates/generic/list_template.html +++ b/cookbook/templates/generic/list_template.html @@ -9,7 +9,7 @@ {% block content %}