From 29aa52aa3dbac3117831c0684242874aa0095b0b Mon Sep 17 00:00:00 2001 From: smilerz Date: Tue, 4 Jan 2022 14:21:01 -0600 Subject: [PATCH] fix saving old list --- cookbook/serializer.py | 29 ++++++++++--------- .../ShoppingListView/ShoppingListView.vue | 8 +++++ vue/src/locales/en.json | 3 +- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index c43b52a7c..f2c41dfe0 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -687,20 +687,21 @@ class ShoppingListEntrySerializer(WritableNestedModelSerializer): return fields def run_validation(self, data): - if ( - data.get('checked', False) - and self.root.instance - and not self.root.instance.checked - ): - # if checked flips from false to true set completed datetime - data['completed_at'] = timezone.now() - elif not data.get('checked', False): - # if not checked set completed to None - data['completed_at'] = None - else: - # otherwise don't write anything - if 'completed_at' in data: - del data['completed_at'] + if self.root.instance.__class__.__name__ == 'ShoppingListEntry': + if ( + data.get('checked', False) + and self.root.instance + and not self.root.instance.checked + ): + # if checked flips from false to true set completed datetime + data['completed_at'] = timezone.now() + elif not data.get('checked', False): + # if not checked set completed to None + data['completed_at'] = None + else: + # otherwise don't write anything + if 'completed_at' in data: + del data['completed_at'] return super().run_validation(data) diff --git a/vue/src/apps/ShoppingListView/ShoppingListView.vue b/vue/src/apps/ShoppingListView/ShoppingListView.vue index 465e52f91..182c76c4e 100644 --- a/vue/src/apps/ShoppingListView/ShoppingListView.vue +++ b/vue/src/apps/ShoppingListView/ShoppingListView.vue @@ -504,6 +504,14 @@ + + {{ $t("mark_complete") }} +