Пример #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)
Пример #2
0
 def post(self, *args, **kwargs):
     if all([self.request.POST.get('eng_verb_infinitive') == self.verb.infinitive,
             self.request.POST.get('eng_verb_past_simple') == self.verb.past_simple,
             self.request.POST.get('eng_verb_past_participle') == self.verb.past_participle
             ]):
         return HttpResponseRedirect(reverse('verb_view', kwargs={'pk': Verb.get_random_verb().id}))
     else:
         self.verb.incorrect_amount += 1
         self.verb.save()
         return render(
             self.request,
             'verbs/verb_error.html',
             {'verb': self.verb}
         )
Пример #3
0
 def get_random_verb(self):
     return Verb.get_random_verb()