From 106a612821898f93c98797779eb92336c2d483e0 Mon Sep 17 00:00:00 2001 From: Andrew Buss Date: Sun, 17 May 2015 00:25:13 -0700 Subject: [PATCH] fixed is_hidden_from --- flashcards/models.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/flashcards/models.py b/flashcards/models.py index a01ec31..d00f8b3 100644 --- a/flashcards/models.py +++ b/flashcards/models.py @@ -1,5 +1,3 @@ -from datetime import datetime - from django.contrib.auth.models import AbstractUser, UserManager from django.core.exceptions import PermissionDenied from django.db.models import * @@ -127,9 +125,9 @@ class Flashcard(Model): :param user: :return: Whether the card is hidden from the user. """ - result = user.userflashcard_set.filter(flashcard=self) - if not result.exists(): return self.is_hidden - return result[0].is_hidden() + if self.userflashcard_set.filter(user=user).exists(): return False + if self.is_hidden or self.flashcardhide_set.filter(user=user).exists(): return True + return False def edit(self, user, new_flashcard): """ -- 1.9.1