def app_list(appname): sort = [("_id", 1)] app_cursor = App.find_app(appname, {}, fields=None).sort(sort) total = App.find_app(appname, {}).count() apps = [] for item in app_cursor: item["id"] = item.pop("_id") apps.append(item) data = {} data.setdefault("items", apps) data.setdefault("total", total) return json_response_ok(data)
def order_app(appname, projectname, apps): sort = [("order", 1), ("_id", 1)] cond = {"app_name": projectname, "name": {"$in": apps}} app_cursor = App.find_app(appname, cond, fields=None).sort(sort) app_names = [] app_names = [item["name"] for item in app_cursor] return app_names