當前位置: 首頁>>代碼示例>>Python>>正文


Python UserProfile.list_by_service_role_email方法代碼示例

本文整理匯總了Python中rogerthat.models.UserProfile.list_by_service_role_email方法的典型用法代碼示例。如果您正苦於以下問題:Python UserProfile.list_by_service_role_email方法的具體用法?Python UserProfile.list_by_service_role_email怎麽用?Python UserProfile.list_by_service_role_email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rogerthat.models.UserProfile的用法示例。


在下文中一共展示了UserProfile.list_by_service_role_email方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_service_grants

# 需要導入模塊: from rogerthat.models import UserProfile [as 別名]
# 或者: from rogerthat.models.UserProfile import list_by_service_role_email [as 別名]
def get_service_grants(service_user, filtered_service_identity=ServiceIdentity.DEFAULT, filtered_role_id=None,
                       filtered_role_type=None):
    from rogerthat.bizz.roles import ROLE_TYPE_ADMIN, ROLE_TYPE_SERVICE
    service_user_email = service_user.email()
    if not isinstance(service_user_email, unicode):
        service_user_email = service_user_email.decode('utf-8')

    profiles = UserProfile.list_by_service_role_email(service_user_email)
    for p in profiles:
        for si, roles in p.grants.iteritems():
            if si.startswith(service_user_email + '/'):
                _, identity = get_service_identity_tuple(users.User(si))
                if filtered_service_identity != ServiceIdentity.DEFAULT and identity != filtered_service_identity:
                    continue
                for role in roles:
                    gto = GrantTO()
                    try:
                        role_id = int(role)
                        role_type = ROLE_TYPE_SERVICE
                        role = None
                    except ValueError:  # build-int role (see ROLES constant)
                        role_id = -1
                        role_type = ROLE_TYPE_ADMIN
                    gto.role_type = role_type
                    gto.role_id = role_id
                    gto.role = role

                    if filtered_role_id is not None and filtered_role_id != gto.role_id:
                        continue
                    if filtered_role_type is not None and filtered_role_type != gto.role_type:
                        continue

                    gto.identity = identity
                    gto.service_email = service_user_email
                    gto.user_email = get_human_user_from_app_user(p.user).email()
                    gto.user_name = p.name
                    gto.user_avatar_id = p.avatarId
                    gto.app_id = p.app_id
                    yield gto
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:41,代碼來源:roles.py


注:本文中的rogerthat.models.UserProfile.list_by_service_role_email方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。