コード例 #1
0
ファイル: tests.py プロジェクト: optimistiks/ezdict_api
 def createCardMeaning(self, user, card, text):
     cardMeaning = CardMeaning()
     cardMeaning.user = user
     cardMeaning.card = card
     cardMeaning.text = text
     cardMeaning.save()
     return cardMeaning
コード例 #2
0
ファイル: handlers.py プロジェクト: optimistiks/ezdict_api
def addToLearning(sender, instance, **kwargs):
    history = instance
    card = Card().findByUserAndText(history.user, history.string)
    if history.count >= WARN_LEVEL_5:
        if card is None:
            card = Card()
            card.text = history.string
            card.user = history.user
            card.save()
            profile = UserProfile().findByUser(card.user)
            meanings = get_flat_meanings(card.text, profile.target_lang)
            for meaning in meanings:
                cardMeaning = CardMeaning()
                cardMeaning.text = meaning
                cardMeaning.card = card
                cardMeaning.user = card.user
                cardMeaning.save()
        try:
            card.to_study
        except CardToStudy.DoesNotExist:
            cardToStudy = CardToStudy()
            cardToStudy.card = card
            cardToStudy.user = card.user
            cardToStudy.save()