本文整理汇总了Python中flask.ext.principal.Permission.union方法的典型用法代码示例。如果您正苦于以下问题:Python Permission.union方法的具体用法?Python Permission.union怎么用?Python Permission.union使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask.ext.principal.Permission
的用法示例。
在下文中一共展示了Permission.union方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: consignment
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def consignment(id_=None):
import litefac.apis as apis
from flask.ext.principal import Permission
Permission.union(CargoClerkPermission, AccountantPermission).test()
if request.method == "GET":
cons = apis.delivery.get_consignment(id_)
team_list = apis.manufacture.get_team_list()
if not cons:
abort(404)
else:
return dict(plate=cons.plate, consignment=cons, titlename=u'发货单详情',
team_list=team_list)
else:
if id_:
cons = apis.delivery.get_consignment(id_)
if not cons:
abort(404)
params = {}
if request.form:
params["pay_in_cash"] = request.form.get("pay_in_cash",
type=int)
params["notes"] = request.form.get("notes")
try:
cons.update(cons.id, **params)
if CargoClerkPermission.can():
flash(u"更新成功")
except ValueError, e:
flash(unicode(e.message), "error")
else:
if cons.pay_in_cash:
cons.paid()
flash(u"支付成功")
return redirect(url_for("delivery.consignment", id_=id_,
url=request.form.get("url")))
示例2: consignment_product
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def consignment_product(id_):
from flask.ext.principal import Permission
Permission.union(CargoClerkPermission, AccountantPermission).test()
import litefac.apis as apis
current_product = apis.delivery.ConsignmentProductWrapper.get_product(id_)
if current_product:
if request.method == "GET":
return dict(current=current_product,
product_types=apis.product.get_product_types(),
products=json.dumps(apis.product.get_products()),
team_list=apis.manufacture.get_team_list(),
titlename=u"发货产品详情")
else:
class ProductForm(Form):
team_id = IntegerField("team_id")
product_id = IntegerField("product_id")
weight = IntegerField("weight")
returned_weight = IntegerField("returned_weight")
spec = TextField("spec")
type = TextField("type")
unit = TextField("unit")
form = ProductForm(request.form)
current_product.update(**form.data)
return redirect(
request.form.get("url") or url_for("delivery.consignment",
id_=current_product.consignment.id))
else:
return _(u"没有该产品编号:%d" + id_), 404
示例3: consignment_preview
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def consignment_preview(id_):
from flask.ext.principal import Permission
Permission.union(CargoClerkPermission, AccountantPermission).test()
import lite_mms.apis as apis
cons = apis.delivery.get_consignment(id_)
if not cons:
abort(404)
else:
per_page = apis.config.get("print_count_per_page", 5.0, type=float)
import math
pages = int(math.ceil(len(cons.product_list) / per_page))
return dict(plate=cons.plate, consignment=cons, titlename=u'发货单详情',
pages=pages, per_page=per_page)
示例4: test_permission_and
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def test_permission_and():
p1 = Permission(RolePermit('boss'))
p2 = Permission(RolePermit('lackey'))
p3 = p1 & p2
p4 = p1.union(p2)
assert p3.allow == p4.allow
示例5: test_permission_union_denial
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def test_permission_union_denial():
p1 = Permission(('a', 'b'))
p2 = Denial(('a', 'c'))
p3 = p1.union(p2)
assert p1.issubset(p3)
assert p2.issubset(p3)
示例6: try_edit
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def try_edit(self, processed_objs=None):
Permission.union(SchedulerPermission, CargoClerkPermission).test()
if processed_objs:
if processed_objs[0].order.refined or processed_objs[0].order.dispatched:
raise PermissionDenied
示例7: try_view
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def try_view(self, processed_objs=None):
from flask.ext.principal import Permission
Permission.union(CargoClerkPermission, AdminPermission).test()
示例8: try_view_report
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def try_view_report(self):
Permission.union(AdminPermission, AccountantPermission).test()
示例9: try_edit_data_set
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def try_edit_data_set(self):
Permission.union(AdminPermission, AccountantPermission).test()
示例10:
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
permissions=[CargoClerkPermission.union(AccountantPermission)], group=u"发货管理")
nav_bar.register(manufacture_page, name=u"工单管理",
permissions=[SchedulerPermission])
nav_bar.register(store_bill_page, name=u"仓单管理",
default_url="/store/store-bill-list",
permissions=[QualityInspectorPermission])
nav_bar.register(qir_page, name=u"质检报告", default_url="/qir/qireport-list",
permissions=[QualityInspectorPermission])
nav_bar.register(deduction_page, name=u"扣重管理", default_url="/deduction/",
permissions=[QualityInspectorPermission])
nav_bar.register(dashboard, name=u"仪表盘", permissions=[AdminPermission])
nav_bar.register(time_line_page, name=u"时间线", default_url="/timeline/log-list")
nav_bar.register(admin_page, name=u"管理中心", default_url="/admin/user-list", permissions=[AdminPermission])
nav_bar.register(report_page, name=u"报表列表", default_url="/report/report-list",
permissions=[Permission.union(AdminPermission, AccountantPermission)], group=u'报表',
enabler=lambda nav: request.path.startswith('/report/report'))
nav_bar.register(report_page, name=u"数据集合列表", default_url="/report/data-sets",
permissions=[Permission.union(AdminPermission, AccountantPermission)], group=u'报表',
enabler=lambda nav: request.path.startswith('/report/data-set'))
nav_bar.register(report_page, name=u"推送列表", default_url="/report/notification-list",
permissions=[Permission.union(AdminPermission, AccountantPermission)], group=u'报表',
enabler=lambda nav: request.path.startswith('/report/notification-list'))
nav_bar.register(to_do_page, name=u"待办事项", default_url="/todo/todo-list", count=0)
nav_bar.register(work_flow_page, name=lambda: u"工作流",
count=lambda: models.Node.query.filter(models.Node.handle_time == None).count(),
default_url="/work-flow/node-list", permissions=[CargoClerkPermission])
#install jinja utilities
from lite_mms.utilities import url_for_other_page, datetimeformat
from lite_mms import permissions
示例11: has_passed
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
admit = Admit.lookup_from_account_id(current_user.id)
deadline = admit.get_deadline()
too_late = has_passed(deadline)
completed = admit.get_admit_data()['graduation'] is not None
confirmed = admit.is_confirmed()
profile_deadline = dates['profile_update_closing']
hacker = Hacker.lookup_from_account_id(current_user.id)
mit = (hacker.school_id == 166683)
travel = admit.travel
return {'name':'admit_dashboard.html', 'context':{'deadline':format_utc_datetime(deadline, eastern), 'completed':completed, 'confirmed':confirmed, 'too_late':too_late, 'profile_update_deadline':format_utc_datetime(profile_deadline, eastern), 'mit':mit, 'travel':travel}}
ConfirmationPermission = Permission(AttributeNeed('admit', 'pending'))
UpdatePermission = Permission(AttributeNeed('admit', 'update'))
ResumePermission = ConfirmationPermission.union(UpdatePermission)
register_policy_route('/accounts/<int:account_id>/resume/policy', 'resume', ResumePermission, lambda kwargs: 'accounts/' + str(kwargs['account_id']) + '/resume.pdf')
register_policy_route('/accounts/<int:account_id>/travel/policy', 'travel', ConfirmationPermission, lambda kwargs: 'accounts/' + str(kwargs['account_id']) + '/travel.pdf')
@bp.route('/confirmation')
@ConfirmationPermission.require()
def confirmation():
attendee = Attendee.lookup_from_account_id(current_user.id).get_attendee_data()
if attendee['badge_name'] is None:
attendee['badge_name'] = current_user.get_name()
admit = Admit.lookup_from_account_id(current_user.id).get_admit_data()
admit['deadline'] = format_utc_datetime(Admit.lookup_from_account_id(current_user.id).get_deadline(), eastern)
示例12: try_view
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def try_view(self, objs=None):
Permission.union(AdminPermission, CargoClerkPermission).test()
示例13:
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
#default_url="/delivery/consignment-list",
#permissions=[AccountantPermission])
nav_bar.register(manufacture_page, name=u"质检管理",
default_url="/manufacture/qir-list",
permissions=[DepartmentLeaderPermission])
nav_bar.register(store_bill_page, name=u"仓单管理",
default_url="/store/store-bill-list",
permissions=[QualityInspectorPermission])
nav_bar.register(deduction_page, name=u"扣重管理", default_url="/deduction/",
permissions=[QualityInspectorPermission])
nav_bar.register(dashboard, name=u"仪表盘", permissions=[AdminPermission])
nav_bar.register(time_line_page, name=u"时间线", default_url="/timeline/log-list")
nav_bar.register(search_page, name=u"搜索", default_url="/search/search")
nav_bar.register(admin2_page, name=u"管理中心", default_url="/admin2/user-list", permissions=[AdminPermission])
nav_bar.register(report_page, name=u"报表列表", default_url="/report/report-list", permissions=[Permission.union(AdminPermission, AccountantPermission)], group=u'报表',
enabler=lambda nav: request.path.startswith('/report/report'))
nav_bar.register(report_page, name=u"数据集合列表", default_url="/report/data-sets", permissions=[Permission.union(AdminPermission, AccountantPermission)], group=u'报表',
enabler=lambda nav: request.path.startswith('/report/data-set'))
nav_bar.register(report_page, name=u"推送列表", default_url="/report/notification-list", permissions=[Permission.union(AdminPermission, AccountantPermission)], group=u'报表',
enabler=lambda nav: request.path.startswith('/report/notification-list'))
nav_bar.register(to_do_page, name=u"待办事项", default_url="/todo/todo-list")
nav_bar.register(qir_page, name=u"质检报告", default_url="/qir/qireport-list", permissions=[QualityInspectorPermission])
nav_bar.register(work_flow_page, name=lambda: u"工作流(%d)" % models.Node.query.filter(models.Node.handle_time==None).count(),
default_url="/work-flow/node-list", permissions=[CargoClerkPermission])
#install jinja utilities
from litefac.utilities import url_for_other_page, datetimeformat
from litefac.utilities.decorators import after_this_request
from litefac import permissions
示例14: try_
# 需要导入模块: from flask.ext.principal import Permission [as 别名]
# 或者: from flask.ext.principal.Permission import union [as 别名]
def try_(self, preprocessed_objs):
from litefac.permissions import CargoClerkPermission,AdminPermission
from flask.ext.principal import Permission
Permission.union(CargoClerkPermission, AdminPermission).test()