From 99572cfcce0be3f08b38bdb02f3f3d541c7e8d55 Mon Sep 17 00:00:00 2001 From: Andrew Buss Date: Wed, 27 May 2015 22:39:37 -0700 Subject: [PATCH] unpull before reporting --- flashcards/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flashcards/models.py b/flashcards/models.py index c2532e2..1b79d9c 100644 --- a/flashcards/models.py +++ b/flashcards/models.py @@ -16,6 +16,7 @@ from cached_property import cached_property + # Hack to fix AbstractUser before subclassing it AbstractUser._meta.get_field('email')._unique = True @@ -86,7 +87,6 @@ class User(AbstractUser, SimpleEmailConfirmationUserMixin): flashcards.notifications.notify_score_change(flashcard) flashcards.notifications.notify_pull(flashcard) - def unpull(self, flashcard): if not self.is_in_section(flashcard.section): raise ValueError("User not in the section this flashcard belongs to") @@ -251,6 +251,7 @@ class Flashcard(Model): return self def report(self, user, reason=None): + if self.is_in_deck(user): user.unpull(self) obj, created = FlashcardHide.objects.get_or_create(user=user, flashcard=self) obj.reason = reason obj.save() -- 1.9.1