Beispiel #1
0
 def add_route(gid, routes):
     with db.auto_commit():
         Group.get_or_404(id=gid, msg='无指定权限组')
         for route_id in routes:
             Route.get_or_404(id=route_id, msg='无指定路由节点')
             Menu.abort_repeat(group_id=gid, route_id=route_id)
             Menu.create(group_id=gid, route_id=route_id)
Beispiel #2
0
 def add_parent_node(cur_route_node):
     if cur_route_node['parent_id'] == cur_route_node['id'] == 0:
         pass
     else:
         if not (cur_route_node['parent_id'] in id2route_node.keys()
                 or cur_route_node['parent_id'] == 0):
             parent_route = Route.get_or_404(
                 id=cur_route_node['parent_id'])
             id2route_node_clone[parent_route.id] = dict(parent_route)
             add_parent_node(dict(parent_route))
Beispiel #3
0
    def delete(id: int):
        route = Route.get_or_404(id=id, msg='路由不存在, 删除失败')
        # 禁止任意删除
        if Menu.get(route_id=id):
            raise Forbidden(msg='存在权限组的菜单绑定路由,不可删除')

        with db.auto_commit():
            route.delete(commit=False)
            Route.query.filter_by(parent_id=id).delete(
                synchronize_session=False)
Beispiel #4
0
 def create_element(form):
     Route.get_or_404(id=form['route_id'])
     Element.create(**form)
Beispiel #5
0
def get_route_node(id):
    """按ID获取路由节点"""
    route_node = Route.get_or_404(id=id, msg='路由节点不存在')
    return Success(route_node)
Beispiel #6
0
 def update(id: int, **kwargs):
     route = Route.get_or_404(id=id, msg='该节点不存在')
     route.update(**kwargs)