Commit 033fffbf8eae46e59e3163e7cb7f70a2b4261e24
1 parent
6d09e0d28d
Exists in
master
Refactored flashcard list
Showing 2 changed files with 3 additions and 6 deletions Side-by-side Diff
flashcards/models.py
View file @
033fffb
... | ... | @@ -158,7 +158,7 @@ |
158 | 158 | :param user: |
159 | 159 | :return: A queryset with all cards that should be visible to a user. |
160 | 160 | """ |
161 | - return cls.objects.filter(is_hidden=False).exclude(userflashcard__user=user, userflashcard__pulled=None) | |
161 | + return cls.objects.filter(is_hidden=False).exclude(flashcardhide__user=user) | |
162 | 162 | |
163 | 163 | |
164 | 164 | class UserFlashcardQuiz(Model): |
flashcards/views.py
View file @
033fffb
... | ... | @@ -16,7 +16,6 @@ |
16 | 16 | from rest_framework.response import Response |
17 | 17 | from rest_framework.exceptions import AuthenticationFailed, NotAuthenticated, ValidationError, PermissionDenied |
18 | 18 | from simple_email_confirmation import EmailAddress |
19 | -from datetime import datetime | |
20 | 19 | |
21 | 20 | |
22 | 21 | class SectionViewSet(ReadOnlyModelViewSet): |
... | ... | @@ -31,9 +30,7 @@ |
31 | 30 | Gets flashcards for a section, excluding hidden cards. |
32 | 31 | Returned in strictly chronological order (material date). |
33 | 32 | """ |
34 | - flashcards = Flashcard.cards_visible_to(request.user).filter( \ | |
35 | - section=self.get_object(), is_hidden=False).all() | |
36 | - | |
33 | + flashcards = Flashcard.cards_visible_to(request.user).filter(section=self.get_object()) | |
37 | 34 | return Response(FlashcardSerializer(flashcards, many=True).data) |
38 | 35 | |
39 | 36 | @detail_route(methods=['post'], permission_classes=[IsAuthenticated]) |
... | ... | @@ -89,7 +86,7 @@ |
89 | 86 | """ |
90 | 87 | qs = Flashcard.objects.all() |
91 | 88 | qs = qs.filter(userflashcard__user=request.user) |
92 | - qs = qs.filter(section = self.get_object()) | |
89 | + qs = qs.filter(section=self.get_object()) | |
93 | 90 | serializer = FlashcardSerializer(qs, many=True) |
94 | 91 | return Response(serializer.data) |
95 | 92 |