Commit 106a612821898f93c98797779eb92336c2d483e0

Authored by Andrew Buss
1 parent 6e9adabd2b
Exists in master

fixed is_hidden_from

Showing 1 changed file with 3 additions and 5 deletions Side-by-side Diff

flashcards/models.py View file @ 106a612
1   -from datetime import datetime
2   -
3 1 from django.contrib.auth.models import AbstractUser, UserManager
4 2 from django.core.exceptions import PermissionDenied
5 3 from django.db.models import *
... ... @@ -127,9 +125,9 @@
127 125 :param user:
128 126 :return: Whether the card is hidden from the user.
129 127 """
130   - result = user.userflashcard_set.filter(flashcard=self)
131   - if not result.exists(): return self.is_hidden
132   - return result[0].is_hidden()
  128 + if self.userflashcard_set.filter(user=user).exists(): return False
  129 + if self.is_hidden or self.flashcardhide_set.filter(user=user).exists(): return True
  130 + return False
133 131  
134 132 def edit(self, user, new_flashcard):
135 133 """