Beispiel #1
0
 def create(self, request, *args, **kwargs):
     user_obj = request.user
     card_type = 'strengthen_card'
     word_index = request.data.get('word_index', None)
     if not is_exist_log(
             user_obj=user_obj, card_type=card_type, word_index=word_index):
         raise custom_exceptions.Status_404('没有找到对应的卡片')
     data = self.strengthen_update()
     return Response(data)
Beispiel #2
0
def get_word_obj(word_index):
    word_obj = EnglishWordModel.objects.filter(pk=word_index).first()
    if not word_obj:
        raise custom_exceptions.Status_404('没有找到这个单词')
    return word_obj
Beispiel #3
0
 def list(self, request, *args, **kwargs):
     card = get_card(request.user)
     if not card:
         raise custom_exceptions.Status_404('当前时间没有产生新的卡片')
     return Response(card)
Beispiel #4
0
 def validate_username(self, username):
     user_obj = UserModel.objects.filter(username=username).first()
     if user_obj:
         return user_obj
     else:
         raise custom_exceptions.Status_404('用户不存在')