def post(self): # figure out if we pressed the reset button if self.get_argument("action", None) == "reset": models.reset_quizzes() self.render("quizzes.html", quizzes=models.get_quizzes()) # get the words corresponding to a tag and randomize their order words = [result.word_id for result in models.get_words_with_tag(self.get_argument("tag"))] # Check to see if there are any words # TODO(hammer): Should probably tell the user what's up here if len(words) == 0: self.render("quizzes.html", quizzes=models.get_quizzes()) # store the new quiz models.put_quiz(self.get_argument("tag"), self.get_argument("front"), int(time.time()), words) # Re-render the quizzes page self.render("quizzes.html", quizzes=models.get_quizzes())
def get(self): words = models.get_words() tag = self.get_argument("tag", None) if tag: words = models.get_words([str(w.word_id) for w in models.get_words_with_tag(tag)]) self.render("words.html", words=words, new_word=None, edited_word=None)