Exemplo n.º 1
0
def put_new_menu():
    for item in BRAND_MENU:
        menu = CPMenu()
        menu.order = item["order"]
        menu.first_lvl = item["name"]

        for val in item["sub-menu"]:
            sub_menu = CPMenuItem()
            sub_menu.name = val["name"]
            sub_menu.link = val["link"]
            sub_menu.order = val["order"]
            menu.second_lvl.append(sub_menu.serialize())

        menu._id = CPMenu.collection().insert(menu.serialize())

    return menu
Exemplo n.º 2
0
def clear_menu():
    CPMenu.collection().remove()