Esempio n. 1
0
    def get(self, *args, **kwargs):
        themes = Theme.get_publish_themes()
        data = {
            'word_id': Word.get_random_word(themes).id,
            'repeat_word_id': Word.get_repeat_random_word(themes).id,
            'verb_id': Verb.get_random_verb().id
        }

        return render(self.request, self.template_name, data)
Esempio n. 2
0
 def post(self, *args, **kwargs):
     if self.request.POST.get('eng_word') == self.get_check_word():
         self.word.increment_count()
         return HttpResponseRedirect(reverse('word', kwargs={'pk': Word.get_random_word(self.themes).id}))
     else:
         self.word.increment_incorrect_amount()
         return render(
             self.request,
             'words/word_error.html',
             {'word': self.word, 'themes': self.themes}
         )
Esempio n. 3
0
    def post(self, *args, **kwargs):
        # rus_word = self.request.POST.get('rus_word')

        # if rus_word and rus_word in self.word.rus:
        if self.kwargs['pk'] in self.request.POST:
            self.word.increment_count()
            return HttpResponseRedirect(reverse('russian_word', kwargs={'pk': Word.get_random_word(self.themes).id}))
        else:
            self.word.increment_incorrect_amount()
            return render(
                self.request,
                'words/rus_word_error.html',
                {'word': self.word, 'themes': self.themes}
            )
Esempio n. 4
0
 def get_random_word(self):
     return Word.get_random_word(self.themes)