本文整理汇总了Python中app.utils.module.ModuleAPI.can_read方法的典型用法代码示例。如果您正苦于以下问题:Python ModuleAPI.can_read方法的具体用法?Python ModuleAPI.can_read怎么用?Python ModuleAPI.can_read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.utils.module.ModuleAPI
的用法示例。
在下文中一共展示了ModuleAPI.can_read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: group_api_get_users
# 需要导入模块: from app.utils.module import ModuleAPI [as 别名]
# 或者: from app.utils.module.ModuleAPI import can_read [as 别名]
def group_api_get_users(group_id):
if not (ModuleAPI.can_read("group")):
return abort(403)
group = Group.query.get(group_id)
users = group.users.order_by(User.first_name, User.last_name).all()
res = [{"val": user.id, "label": user.name} for user in users]
return jsonify(users=res)
示例2: view_users
# 需要导入模块: from app.utils.module import ModuleAPI [as 别名]
# 或者: from app.utils.module.ModuleAPI import can_read [as 别名]
def view_users(group_id):
if not (ModuleAPI.can_read("group")):
return abort(403)
group = Group.query.filter(Group.id == group_id).first()
if not group:
flash("There is no such group.")
return redirect(url_for("group.view"))
users = group.users.order_by(User.first_name).order_by(User.last_name).all()
return render_template("group/view_users.htm", group=group, users=users, title="%s users" % (group.name))
示例3: get_group_users
# 需要导入模块: from app.utils.module import ModuleAPI [as 别名]
# 或者: from app.utils.module.ModuleAPI import can_read [as 别名]
def get_group_users(group_id):
if not (ModuleAPI.can_read("group")):
return abort(403)
group = Group.query.filter(Group.id == group_id).first()
if not group:
flash("There is no such group.")
return redirect(url_for("group.view"))
users = group.users.all()
user_list = [[user.id, user.name] for user in users]
user_list.sort()
return json.dumps({"data": user_list})
示例4: view
# 需要导入模块: from app.utils.module import ModuleAPI [as 别名]
# 或者: from app.utils.module.ModuleAPI import can_read [as 别名]
def view(page_nr=1):
if not (ModuleAPI.can_read("group")):
return abort(403)
form = ViewGroupForm(request.form)
pagination = Group.query.order_by(Group.name).paginate(page_nr, 15, False)
if form.validate_on_submit():
if form.delete_group.data:
if ModuleAPI.can_write("group"):
group_ids = []
for group, form_entry in zip(pagination.items, form.entries):
if form_entry.select.data:
group_ids.append(group.id)
groups = Group.query.filter(Group.id.in_(group_ids)).all()
for group in groups:
db.session.delete(group)
db.session.commit()
if len(groups) > 1:
flash("The selected groups have been deleted.", "success")
else:
flash("The selected group has been deleted.", "success")
return redirect(url_for("group.view"))
else:
flash("This incident has been reported to our authorities.", "warning")
else:
for group in pagination.items:
form.entries.append_entry()
flash_form_errors(form)
return render_template(
"group/view.htm",
form=form,
pagination=pagination,
groups=zip(pagination.items, form.entries),
current_user=current_user,
title="Groups",
)