示例#1
0
 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/>"""
示例#2
0
    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())
示例#3
0
 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)
示例#4
0
 def detach(self,item,parent_id):
     parent = Item.get(parent_id)
     parent.remove_child(item)
     raise redirect("/item/%d/" % item.id)
示例#5
0
 def query(self,id):
     return Item.select(Item.q.id==int(id))
示例#6
0
 def default(self,item_id):
     return dict(item=Item.get(item_id))
示例#7
0
 def add_child(self,item,item_id):
     item.add_child(Item.get(item_id))
     raise redirect(referer())