def getChildCategories(self, parent, **kwargs): cat = Category.get(parent) children = cat.get_children() response = [] for x in children: tmp = api.Category.new_message() tmp.id = str(x.category_id) tmp.name = x.child_category_name response.append(tmp) return response
from killranswers import Question, Category, User from uuid import uuid4, uuid1 root = Category.get_root() def get_cat(): # how to get those awesome scaffolds # TODO: use test name instead of the hard coded name return root.create_sub("category-test") def get_user(): return User.create(uuid1()) def test_ask(): c = get_cat() q = Question.create(c, "test question", get_user())
def createCategory(self, text, parent, **kwargs): p = Category.get(category_id=parent) cat = p.create_sub(text) return str(cat.category_id)
def getRootCategory(self, **kwargs): root = Category.get_root() cat = api.Category.new_message() cat.id = str(root.category_id) cat.name = root.name return cat
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)