本文整理汇总了Python中assembl.models.Idea.uri方法的典型用法代码示例。如果您正苦于以下问题:Python Idea.uri方法的具体用法?Python Idea.uri怎么用?Python Idea.uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assembl.models.Idea
的用法示例。
在下文中一共展示了Idea.uri方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_idea
# 需要导入模块: from assembl.models import Idea [as 别名]
# 或者: from assembl.models.Idea import uri [as 别名]
def create_idea(request):
discussion_id = int(request.matchdict['discussion_id'])
session = Discussion.default_db
discussion = session.query(Discussion).get(int(discussion_id))
user_id = request.authenticated_userid
permissions = get_permissions(user_id, discussion.id)
idea_data = json.loads(request.body)
kwargs = {
"discussion": discussion
}
for key, attr_name in langstring_fields.iteritems():
if key in idea_data:
ls_data = idea_data[key]
if ls_data is None:
continue
assert isinstance(ls_data, dict)
current = LangString.create_from_json(
ls_data, user_id, permissions=permissions)
kwargs[attr_name] = current
new_idea = Idea(**kwargs)
session.add(new_idea)
if idea_data['parentId']:
parent = Idea.get_instance(idea_data['parentId'])
else:
parent = discussion.root_idea
session.add(IdeaLink(source=parent, target=new_idea, order=idea_data.get('order', 0.0)))
session.flush()
return {'ok': True, '@id': new_idea.uri()}
示例2: create_idea
# 需要导入模块: from assembl.models import Idea [as 别名]
# 或者: from assembl.models.Idea import uri [as 别名]
def create_idea(request):
discussion_id = int(request.matchdict["discussion_id"])
session = Discussion.default_db
discussion = session.query(Discussion).get(int(discussion_id))
idea_data = json.loads(request.body)
new_idea = Idea(short_title=idea_data["shortTitle"], long_title=idea_data["longTitle"], discussion=discussion)
session.add(new_idea)
if idea_data["parentId"]:
parent = Idea.get_instance(idea_data["parentId"])
else:
parent = discussion.root_idea
session.add(IdeaLink(source=parent, target=new_idea, order=idea_data.get("order", 0.0)))
session.flush()
return {"ok": True, "@id": new_idea.uri()}
示例3: create_idea
# 需要导入模块: from assembl.models import Idea [as 别名]
# 或者: from assembl.models.Idea import uri [as 别名]
def create_idea(request):
discussion_id = int(request.matchdict['discussion_id'])
session = Discussion.db()
discussion = session.query(Discussion).get(int(discussion_id))
idea_data = json.loads(request.body)
new_idea = Idea(
short_title=idea_data['shortTitle'],
long_title=idea_data['longTitle'],
discussion=discussion,
)
session.add(new_idea)
if idea_data['parentId']:
parent = Idea.get_instance(idea_data['parentId'])
else:
parent = discussion.root_idea
session.add(IdeaLink(source=parent, target=new_idea, order=idea_data.get('order', 0.0)))
session.flush()
return {'ok': True, '@id': new_idea.uri()}