From 947d9f740c3bfb59a68fdfdc8e53802faf34eb53 Mon Sep 17 00:00:00 2001 From: Michal Kunc Date: Fri, 17 Feb 2023 15:21:04 +0100 Subject: [PATCH] fix after changing null -> blank --- templates/watchlist/movie_detail.html | 2 +- watchlist/tests/test_views.py | 4 ++-- watchlist/views.py | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/templates/watchlist/movie_detail.html b/templates/watchlist/movie_detail.html index fd88e08..381014b 100644 --- a/templates/watchlist/movie_detail.html +++ b/templates/watchlist/movie_detail.html @@ -14,7 +14,7 @@

Total score: {{ movie.score }}, seen by: {{ movie.seen_score }}.

{% endif %} diff --git a/watchlist/tests/test_views.py b/watchlist/tests/test_views.py index 291e08f..bd527d2 100644 --- a/watchlist/tests/test_views.py +++ b/watchlist/tests/test_views.py @@ -166,10 +166,10 @@ class VoteTests(TestCase): with self.subTest(comment=comment): response = self.client.post(reverse('watchlist:vote', args=(m.id,)), data={"vote": "0", "comment": comment}) mv = m.movievote_set.get(user=self.user) - self.assertEqual(mv.comment, None if comment == "" else comment) + self.assertEqual(mv.comment, comment) with self.subTest(comment=None): response = self.client.post(reverse('watchlist:vote', args=(m.id,)), data={"vote": "0"}) mv = m.movievote_set.get(user=self.user) - self.assertEqual(mv.comment, None) + self.assertEqual(mv.comment, "") diff --git a/watchlist/views.py b/watchlist/views.py index 99ba2a0..36c36eb 100644 --- a/watchlist/views.py +++ b/watchlist/views.py @@ -56,9 +56,7 @@ def vote(request, pk): user_vote.vote = request.POST['vote'] user_vote.seen = request.POST.get('seen', False) == "on" comment = request.POST.get('comment', '').strip() - if comment != '' or user_vote.comment is not None: - if comment == '': - comment = None + if comment != '' or user_vote.comment != "": user_vote.comment = comment user_vote.save() return HttpResponseRedirect(reverse('watchlist:index'))