Commit ef60c52b6fee38deafeea2e4b8fec687eea9c2ec

Authored by Rohan Rangray
Exists in master

Merge branch 'master' of https://git.ucsd.edu/110swag/flashy-backend

Minor merge.

Showing 2 changed files Side-by-side Diff

flashcards/models.py View file @ ef60c52
... ... @@ -113,7 +113,7 @@
113 113 :param user:
114 114 :return: A queryset with all cards that should be visible to a user.
115 115 """
116   - return cls.objects.filter(hidden=False).exclude(userflashcard=user, userflashcard__pulled=None)
  116 + return cls.objects.filter(is_hidden=False).exclude(userflashcard__user=user, userflashcard__pulled=None)
117 117  
118 118  
119 119 class UserFlashcardQuiz(Model):
flashcards/views.py View file @ ef60c52
... ... @@ -24,6 +24,17 @@
24 24 pagination_class = StandardResultsSetPagination
25 25 permission_classes = [IsAuthenticated]
26 26  
  27 + @detail_route(methods=['get'], permission_classes=[IsAuthenticated])
  28 + def flashcards(self, request, pk):
  29 + """
  30 + Gets flashcards for a section, excluding hidden cards.
  31 + Returned in strictly chronological order (material date).
  32 + """
  33 + flashcards = Flashcard.cards_visible_to(request.user).filter( \
  34 + section=self.get_object(), is_hidden=False).all()
  35 +
  36 + return Response(FlashcardSerializer(flashcards, many=True))
  37 +
27 38 @detail_route(methods=['post'], permission_classes=[IsAuthenticated])
28 39 def enroll(self, request, pk):
29 40 """