当前位置: 首页>>代码示例>>Python>>正文


Python current_user.is_superuser方法代码示例

本文整理汇总了Python中flask_login.current_user.is_superuser方法的典型用法代码示例。如果您正苦于以下问题:Python current_user.is_superuser方法的具体用法?Python current_user.is_superuser怎么用?Python current_user.is_superuser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_login.current_user的用法示例。


在下文中一共展示了current_user.is_superuser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_identity_loaded

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_superuser [as 别名]
def on_identity_loaded(sender, identity):
    # Set the identity user object
    identity.user = current_user

    # Add the UserNeed to the identity
    if hasattr(current_user, 'username'):
        identity.provides.add(UserNeed(current_user.username))

    # Assuming the User model has a list of roles, update the
    # identity with the roles that the user provides
    if hasattr(current_user, 'role'):
        # for role in current_user.roles:
        identity.provides.add(RoleNeed(current_user.role))
    
    # if current_user.is_superuser:
    if hasattr(current_user, 'is_superuser') and current_user.is_superuser:
        identity.provides.add(su_need)
        # return current_user.role

    identity.allow_su = su_permission.allows(identity)
    identity.allow_admin = admin_permission.allows(identity)
    identity.allow_edit = editor_permission.allows(identity)
    identity.allow_general = general_permission.allows(identity) 
开发者ID:GitMarkTeam,项目名称:gitmark,代码行数:25,代码来源:permissions.py

示例2: permission_required

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_superuser [as 别名]
def permission_required(permission):
    """A wrapper that checks if the current user
    has the required permissions for a page
      * The annotated function must have a `project` argument for project pages.
      * The current user must be available in `flask_login.current_user`
      * The user object must have a `project_weight(project) method`
    """
    def check_permissions(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if not current_user.is_superuser:
                project = kwargs.get('project', None)
                if project:
                    user_weight = current_user.project_weight(project)
                else:
                    user_weight = 0
                required_weight = Permissions.get_weight(permission)
                if user_weight < required_weight:
                    return render_template('not_permission.html')
            return func(*args, **kwargs)
        return wrapper
    return check_permissions 
开发者ID:golemhq,项目名称:golem,代码行数:24,代码来源:gui_utils.py

示例3: is_accessible

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_superuser [as 别名]
def is_accessible(self):
        if current_user.is_authenticated and current_user.is_superuser:
            return True
        return False 
开发者ID:honmaple,项目名称:maple-file,代码行数:6,代码来源:admin.py

示例4: init_app

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_superuser [as 别名]
def init_app(app):
    @identity_loaded.connect_via(app)
    def on_identity_loaded(sender, identity):
        '''基础权限'''
        identity.user = current_user

        if hasattr(current_user, 'id'):
            identity.provides.add(UserNeed(current_user.id))

        if hasattr(current_user, 'is_superuser'):
            if current_user.is_superuser:
                identity.provides.add(RoleNeed('super'))

        if hasattr(current_user, 'is_confirmed'):
            if current_user.is_confirmed:
                identity.provides.add(RoleNeed('confirmed'))

        if hasattr(current_user, 'is_authenticated'):
            if current_user.is_authenticated:
                identity.provides.add(RoleNeed('auth'))
            else:
                identity.provides.add(RoleNeed('guest'))

        if hasattr(current_user, 'topics'):
            for topic in current_user.topics:
                identity.provides.add(TopicNeed(topic.id))

        if hasattr(current_user, 'replies'):
            for reply in current_user.replies:
                identity.provides.add(ReplyNeed(reply.id))

        if hasattr(current_user, 'collects'):
            for collect in current_user.collects:
                identity.provides.add(CollectNeed(collect.id)) 
开发者ID:honmaple,项目名称:maple-bbs,代码行数:36,代码来源:app.py

示例5: is_accessible

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_superuser [as 别名]
def is_accessible(self):
        return current_user.is_authenticated
        # return current_user.is_superuser


# Create customized index view class 
开发者ID:GitMarkTeam,项目名称:gitmark,代码行数:8,代码来源:admin.py

示例6: index

# 需要导入模块: from flask_login import current_user [as 别名]
# 或者: from flask_login.current_user import is_superuser [as 别名]
def index():
    """If user is admin or has '*' in report permissions they will
    have access to every project. Otherwise limit the project
    list to gui_permissions
    """
    projects = test_directory.get_projects()
    if not current_user.is_superuser:
        user_projects = current_user.project_list
        projects = [p for p in user_projects if p in projects]
    return render_template('index.html', projects=projects)


# PROJECT VIEW - redirect to to /project/suites/ 
开发者ID:golemhq,项目名称:golem,代码行数:15,代码来源:web_app.py


注:本文中的flask_login.current_user.is_superuser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。