Exemplo n.º 1
0
Arquivo: views.py Projeto: tadgh/KW
    def lesson(self, request):
        lessons = get_users_lessons(request.user)
        page = self.paginate_queryset(lessons)
        if page is not None:
            serializer = StubbedReviewSerializer(page, many=True)
            return self.get_paginated_response(serializer.data)

        serializer = StubbedReviewSerializer(lessons, many=True)
        return Response(serializer.data)
Exemplo n.º 2
0
    def lesson(self, request):
        lessons = get_users_lessons(request.user)
        page = self.paginate_queryset(lessons)
        if page is not None:
            serializer = StubbedReviewSerializer(page, many=True)
            return self.get_paginated_response(serializer.data)

        serializer = StubbedReviewSerializer(lessons, many=True)
        return Response(serializer.data)
Exemplo n.º 3
0
    def lesson(self, request):
        lessons = (get_users_lessons(
            request.user).select_related("vocabulary").prefetch_related(
                "meaning_synonyms",
                "reading_synonyms",
                "vocabulary__readings",
                "vocabulary__readings__parts_of_speech",
            ))
        page = self.paginate_queryset(lessons)
        if page is not None:
            serializer = StubbedReviewSerializer(page, many=True)
            return self.get_paginated_response(serializer.data)

        serializer = StubbedReviewSerializer(lessons, many=True)
        return Response(serializer.data)
Exemplo n.º 4
0
    def test_when_user_resets_their_account_we_remove_all_reviews_and_then_unlock_their_current_level(self):
        self.user.profile.unlocked_levels.get_or_create(level=1)
        new_review = create_review(create_vocab("arbitrary word"), self.user)
        new_review.needs_review = True
        new_review.save()
        self.assertEqual(get_users_current_reviews(self.user).count(), 2)

        mock_vocab_list_response_with_single_vocabulary(self.user)
        mock_user_info_response(self.user.profile.api_key)

        reset_user(self.user, 1)

        self.user.refresh_from_db()
        self.user.profile.refresh_from_db()
        self.assertEqual(get_users_lessons(self.user).count(), 0)
        self.assertEqual(self.user.profile.level, 5)
Exemplo n.º 5
0
    def test_when_user_resets_their_account_we_remove_all_reviews_and_then_unlock_their_current_level(
            self):
        return
        self.user.profile.unlocked_levels.get_or_create(level=1)
        new_review = create_review(create_vocab("arbitrary word"), self.user)
        new_review.needs_review = True
        new_review.save()
        self.assertEqual(get_users_current_reviews(self.user).count(), 2)

        # TODO Fill with V2 mocks.

        reset_user(self.user, 1)

        self.user.refresh_from_db()
        self.user.profile.refresh_from_db()
        self.assertEqual(get_users_lessons(self.user).count(), 0)
        self.assertEqual(self.user.profile.level, 5)
Exemplo n.º 6
0
    def test_when_user_resets_their_account_we_remove_all_reviews_and_then_unlock_their_current_level(
        self
    ):
        self.user.profile.unlocked_levels.get_or_create(level=1)
        new_review = create_review(create_vocab("arbitrary word"), self.user)
        new_review.needs_review = True
        new_review.save()
        self.assertEqual(get_users_current_reviews(self.user).count(), 2)

        mock_vocab_list_response_with_single_vocabulary(self.user, self.user.profile.level)
        mock_user_info_response(self.user.profile.api_key)

        reset_user(self.user, 1)

        self.user.refresh_from_db()
        self.user.profile.refresh_from_db()
        self.assertEqual(get_users_lessons(self.user).count(), 0)
        self.assertEqual(self.user.profile.level, 5)
Exemplo n.º 7
0
    def test_users_not_following_wanikani_still_get_vocab_unlocked_when_they_unlock_a_level(
            self):
        mock_user_response_v2()
        mock_assignments_with_one_assignment()
        mock_study_materials()
        mock_subjects_v2()

        self.user.profile.follow_me = False
        self.user.profile.api_key_v2 = "whatever"
        # Clear out all reviews so a level unlock works.
        UserSpecific.objects.filter(user=self.user).delete()
        syncer = WanikaniUserSyncerV2(self.user.profile)
        reviews = get_users_current_reviews(self.user)
        assert reviews.count() == 0
        new_review_count, unlocked_count, locked_count = syncer.unlock_vocab(
            levels=[1])
        assert new_review_count == 1
        reviews = get_users_lessons(self.user)
        assert reviews.count() == 1
Exemplo n.º 8
0
 def get_lessons_count(self, obj):
     return get_users_lessons(obj).count()
Exemplo n.º 9
0
Arquivo: signals.py Projeto: tadgh/KW
def user_still_has_no_lessons(user):
    return get_users_lessons(user).count() == 0
Exemplo n.º 10
0
def user_still_has_no_lessons(user):
    return get_users_lessons(user).count() == 0
Exemplo n.º 11
0
 def get_lessons_count(self, obj):
     return get_users_lessons(obj).count()