本文整理匯總了Python中aleph.model.Role.all方法的典型用法代碼示例。如果您正苦於以下問題:Python Role.all方法的具體用法?Python Role.all怎麽用?Python Role.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類aleph.model.Role
的用法示例。
在下文中一共展示了Role.all方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: index
# 需要導入模塊: from aleph.model import Role [as 別名]
# 或者: from aleph.model.Role import all [as 別名]
def index():
authz.require(authz.logged_in())
users = []
for role in Role.all():
data = role.to_dict()
del data["email"]
users.append(data)
return jsonify({"results": users, "total": len(users)})
示例2: permissions_update
# 需要導入模塊: from aleph.model import Role [as 別名]
# 或者: from aleph.model.Role import all [as 別名]
def permissions_update(collection):
authz.require(authz.collection_write(collection))
data = request_data()
validate(data, "permission.json#")
role = Role.all().filter(Role.id == data["role"]).first()
if role is None:
raise BadRequest()
permission = Permission.grant_collection(collection, role, data["read"], data["write"])
db.session.commit()
log_event(request)
return jsonify({"status": "ok", "updated": permission})
示例3: permissions_update
# 需要導入模塊: from aleph.model import Role [as 別名]
# 或者: from aleph.model.Role import all [as 別名]
def permissions_update(collection):
authz.require(authz.collection_write(collection))
data = request_data()
validate(data, 'permission.json#')
role = Role.all().filter(Role.id == data['role']).first()
if role is None:
raise BadRequest()
permission = Permission.grant_collection(collection.id,
role,
data['read'],
data['write'])
db.session.commit()
return jsonify({
'status': 'ok',
'updated': permission
})