本文整理汇总了Python中models.Node.get_node_choices方法的典型用法代码示例。如果您正苦于以下问题:Python Node.get_node_choices方法的具体用法?Python Node.get_node_choices怎么用?Python Node.get_node_choices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Node
的用法示例。
在下文中一共展示了Node.get_node_choices方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Node [as 别名]
# 或者: from models.Node import get_node_choices [as 别名]
def post(self, urlname):
if not self.has_permission:
return
if not self.current_user.is_admin:
return self.redirect_next_url()
node = Node.get(urlname=urlname)
if not node:
return self.redirect_next_url()
user = self.current_user
args = self.request.arguments
try:
selected = args.get('parent_name')
print(selected)
except:
selected = [n.name for n in node.parent_nodes]
args = {'name': [node.name], 'urlname': [node.urlname],
'description': [node.description], 'style': [node.style]}
form = NodeEditForm.init(Node.get_node_choices(), selected, args=args,
node=node)
if form.validate():
node = form.save(user, node=node)
result = {'status': 'success', 'message': '节点修改成功',
'node_url': node.url}
if self.is_ajax:
return self.write(result)
self.flash_message(result)
return self.redirect(node.url)
if self.is_ajax:
return self.write(form.result)
return self.render("node/edit.html", form=form, node=node)
示例2: get
# 需要导入模块: from models import Node [as 别名]
# 或者: from models.Node import get_node_choices [as 别名]
def get(self):
node_id = int(self.get_argument('node_id', 0))
node = Node.get(id=node_id)
if node:
selected = [node.name]
else:
selected = []
form = NodeForm.init(Node.get_node_choices(), selected)
return self.render("node/create.html", form=form)
示例3: get
# 需要导入模块: from models import Node [as 别名]
# 或者: from models.Node import get_node_choices [as 别名]
def get(self):
node_id = force_int(self.get_argument('node_id', 0), 0)
node = Node.get(id=node_id)
if node:
selected = node.name
else:
selected = None
choices = Node.get_node_choices()
form = TopicForm.init(choices=choices, selected=selected)
return self.render("topic/create.html", form=form, node=node)
示例4: get
# 需要导入模块: from models import Node [as 别名]
# 或者: from models.Node import get_node_choices [as 别名]
def get(self, topic_id):
topic = Topic.get(id=topic_id)
if topic and (topic.author == self.current_user or self.current_user.is_admin):
selected = topic.node.name
else:
return self.redirect_next_url()
choices = Node.get_node_choices()
args = {'node_name': [selected], 'title': [topic.title], 'content':
[topic.content]}
form = TopicForm.init(choices=choices, selected=selected, args=args)
return self.render("topic/create.html", form=form, node=topic.node)
示例5: get
# 需要导入模块: from models import Node [as 别名]
# 或者: from models.Node import get_node_choices [as 别名]
def get(self):
if not self.has_permission:
return
if not self.current_user.is_admin:
return self.redirect_next_url()
node_id = int(self.get_argument('node_id', 0))
node = Node.get(id=node_id)
if node:
selected = [node.name]
else:
selected = []
form = NodeForm.init(Node.get_node_choices(), selected)
return self.render("node/create.html", form=form)
示例6: get
# 需要导入模块: from models import Node [as 别名]
# 或者: from models.Node import get_node_choices [as 别名]
def get(self, topic_id):
if not self.has_permission:
return
topic = Topic.get(id=topic_id)
if topic:
selected = topic.node.name
else:
return self.redirect_next_url()
choices = Node.get_node_choices()
args = {'node_name': [selected], 'title': [topic.title], 'content':
[topic.content]}
form = TopicForm.init(choices=choices, selected=selected, args=args)
return self.render("topic/create.html", form=form, node=topic.node)