def reorder_children(self,item,**kwargs): for k in kwargs.keys(): if k[:5] == "item_": item_id = k[5:] i = Item.get(item_id) li = ListItem.select(AND(ListItem.q.parentID == item.id, ListItem.q.childID == i.id))[0] li.cardinality = int(kwargs[k]) item.normalize_childrens_cardinality() return """<?xml version="1.0"?><done/>"""
def reparent(self,item,item_id): iids = [] if type(item_id) != type([]): iids = [item_id] else: iids = item_id for iid in iids: i = Item.get(iid) i.set_parent(item) raise redirect(referer())
def search(self,q=""): q = q.strip() if q == "": return dict(items=[],item=None,q=q) else: items = list(Item.select(AND(OR(LIKE(Item.q.title,"%%" + q + "%%"), LIKE(Item.q.description,"%%" + q + "%%")), Item.q.ownerID==turbogears.identity.current.user.id ))) return dict(items=items, item=None, q=q)
def detach(self,item,parent_id): parent = Item.get(parent_id) parent.remove_child(item) raise redirect("/item/%d/" % item.id)
def query(self,id): return Item.select(Item.q.id==int(id))
def default(self,item_id): return dict(item=Item.get(item_id))
def add_child(self,item,item_id): item.add_child(Item.get(item_id)) raise redirect(referer())