Пример #1
0
async def add_node(domain_id: str, category_name: str, node_name: str):
    nodes = await get_nodes(domain_id)
    if category_name not in nodes:
        raise error.DiscussionCategoryNotFoundError(domain_id, category_name)
    if _is_exist_node(nodes, node_name):
        raise error.DiscussionNodeAlreadyExistError(domain_id, node_name)
    nodes[category_name].append(node_name)
    await _update_nodes(domain_id, nodes)
Пример #2
0
async def add_node(domain_id: str, category_name: str, node_name: str, node_pic: str=None):
  validator.check_node_name(node_name)
  nodes = await get_nodes(domain_id)
  if category_name not in nodes:
    raise error.DiscussionCategoryNotFoundError(domain_id, category_name)
  if _get_exist_node(nodes, node_name):
    raise error.DiscussionNodeAlreadyExistError(domain_id, node_name)
  nodes[category_name].append({'name': node_name,
                               'pic': node_pic})
  await _update_nodes(domain_id, nodes)