def voteQuestion(self, question, user, vote, **kwargs): log.debug("voting question {} {} {}".format(question, user, vote)) q = Question.get(question) print q u = User.get(user) print u new_rating = q.vote(u, vote) print new_rating return new_rating
def getAnswers(self, question, **kwargs): q = Question.get(question) answers = q.get_answers() resp = [] for a in answers: tmp = api.Answer.new_message() tmp.id = str(a.answer_id) tmp.question = str(a.question_id) tmp.user = str(a.user_id) tmp.text = a.text resp.append(tmp) return resp
def test_ask(): c = get_cat() q = Question.create(c, "test question", get_user())
def answer(self, question, user, text, **kwargs): q = Question.get(question) u = User.get(user) answer = q.answer(user=u, text=text) return str(answer.answer_id)
def ask(self, text, category, user, **kwargs): cat = Category.get(category) u = User.get(user) question = Question.create(cat, text, u) return str(question.question_id)