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


Python algebra.sum_acls函数代码示例

本文整理汇总了Python中misago.acl.algebra.sum_acls函数的典型用法代码示例。如果您正苦于以下问题:Python sum_acls函数的具体用法?Python sum_acls怎么用?Python sum_acls使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: build_category_acl

def build_category_acl(acl, category, categories_roles, key_name):
    if category.level > 1:
        if category.parent_id not in acl['visible_categories']:
            # dont bother with child categories of invisible parents
            return
        elif not acl['categories'][category.parent_id]['can_browse']:
            # parent's visible, but its contents aint
            return

    category_roles = categories_roles.get(category.pk, [])

    final_acl = {
        'can_see': 0,
        'can_browse': 0,
    }

    algebra.sum_acls(final_acl, roles=category_roles, key=key_name,
        can_see=algebra.greater,
        can_browse=algebra.greater
    )

    if final_acl['can_see']:
        acl['visible_categories'].append(category.pk)
        acl['categories'][category.pk] = final_acl

        if final_acl['can_browse']:
            acl['browseable_categories'].append(category.pk)
开发者ID:1905410,项目名称:Misago,代码行数:27,代码来源:permissions.py

示例2: build_category_acl

def build_category_acl(acl, category, categories_roles, key_name):
    category_roles = categories_roles.get(category.pk, [])

    final_acl = {
        'can_see_all_threads': 0,
        'can_start_threads': 0,
        'can_reply_threads': 0,
        'can_edit_threads': 0,
        'can_edit_posts': 0,
        'can_hide_own_threads': 0,
        'can_hide_own_posts': 0,
        'thread_edit_time': 0,
        'post_edit_time': 0,
        'can_hide_threads': 0,
        'can_hide_posts': 0,
        'can_protect_posts': 0,
        'can_move_posts': 0,
        'can_merge_posts': 0,
        'can_pin_threads': 0,
        'can_close_threads': 0,
        'can_move_threads': 0,
        'can_merge_threads': 0,
        'can_approve_content': 0,
        'can_report_content': 0,
        'can_see_reports': 0,
        'can_see_posts_likes': 0,
        'can_like_posts': 0,
        'can_hide_events': 0,
    }
    final_acl.update(acl)

    algebra.sum_acls(final_acl, roles=category_roles, key=key_name,
        can_see_all_threads=algebra.greater,
        can_start_threads=algebra.greater,
        can_reply_threads=algebra.greater,
        can_edit_threads=algebra.greater,
        can_edit_posts=algebra.greater,
        can_hide_threads=algebra.greater,
        can_hide_posts=algebra.greater,
        can_hide_own_threads=algebra.greater,
        can_hide_own_posts=algebra.greater,
        thread_edit_time=algebra.greater_or_zero,
        post_edit_time=algebra.greater_or_zero,
        can_protect_posts=algebra.greater,
        can_move_posts=algebra.greater,
        can_merge_posts=algebra.greater,
        can_pin_threads=algebra.greater,
        can_close_threads=algebra.greater,
        can_move_threads=algebra.greater,
        can_merge_threads=algebra.greater,
        can_approve_content=algebra.greater,
        can_report_content=algebra.greater,
        can_see_reports=algebra.greater,
        can_see_posts_likes=algebra.greater,
        can_like_posts=algebra.greater,
        can_hide_events=algebra.greater,
    )

    return final_acl
开发者ID:1905410,项目名称:Misago,代码行数:59,代码来源:threads.py

示例3: add_acl_to_category

def add_acl_to_category(user, category):
    category_acl = user.acl['categories'].get(category.pk, {})

    category.acl.update({
        'can_see_all_threads': 0,
        'can_start_threads': 0,
        'can_reply_threads': 0,
        'can_edit_threads': 0,
        'can_edit_posts': 0,
        'can_hide_own_threads': 0,
        'can_hide_own_posts': 0,
        'thread_edit_time': 0,
        'post_edit_time': 0,
        'can_hide_threads': 0,
        'can_hide_posts': 0,
        'can_protect_posts': 0,
        'can_move_posts': 0,
        'can_merge_posts': 0,
        'can_pin_threads': 0,
        'can_close_threads': 0,
        'can_move_threads': 0,
        'can_merge_threads': 0,
        'can_split_threads': 0,
        'can_review_moderated_content': 0,
        'can_report_content': 0,
        'can_see_reports': 0,
        'can_hide_events': 0,
    })

    algebra.sum_acls(category.acl, acls=[category_acl],
        can_see_all_threads=algebra.greater)

    if user.is_authenticated():
        algebra.sum_acls(category.acl, acls=[category_acl],
            can_start_threads=algebra.greater,
            can_reply_threads=algebra.greater,
            can_edit_threads=algebra.greater,
            can_edit_posts=algebra.greater,
            can_hide_threads=algebra.greater,
            can_hide_posts=algebra.greater,
            can_hide_own_threads=algebra.greater,
            can_hide_own_posts=algebra.greater,
            thread_edit_time=algebra.greater_or_zero,
            post_edit_time=algebra.greater_or_zero,
            can_protect_posts=algebra.greater,
            can_move_posts=algebra.greater,
            can_merge_posts=algebra.greater,
            can_pin_threads=algebra.greater,
            can_close_threads=algebra.greater,
            can_move_threads=algebra.greater,
            can_merge_threads=algebra.greater,
            can_split_threads=algebra.greater,
            can_review_moderated_content=algebra.greater,
            can_report_content=algebra.greater,
            can_see_reports=algebra.greater,
            can_hide_events=algebra.greater,
        )

    category.acl['can_see_own_threads'] = not category.acl['can_see_all_threads']
开发者ID:fengrussell,项目名称:Misago,代码行数:59,代码来源:threads.py

示例4: build_forum_acl

def build_forum_acl(acl, forum, forums_roles, key_name):
    forum_roles = forums_roles.get(forum.pk, [])

    final_acl = {
        'can_see_all_threads': 0,
        'can_start_threads': 0,
        'can_reply_threads': 0,
        'can_edit_threads': 0,
        'can_edit_posts': 0,
        'can_hide_own_threads': 0,
        'can_hide_own_posts': 0,
        'thread_edit_time': 0,
        'post_edit_time': 0,
        'can_hide_threads': 0,
        'can_hide_posts': 0,
        'can_protect_posts': 0,
        'can_move_posts': 0,
        'can_merge_posts': 0,
        'can_change_threads_labels': 0,
        'can_pin_threads': 0,
        'can_close_threads': 0,
        'can_move_threads': 0,
        'can_merge_threads': 0,
        'can_split_threads': 0,
        'can_review_moderated_content': 0,
        'can_report_content': 0,
        'can_see_reports': 0,
        'can_hide_events': 0,
    }
    final_acl.update(acl)

    algebra.sum_acls(final_acl, roles=forum_roles, key=key_name,
        can_see_all_threads=algebra.greater,
        can_start_threads=algebra.greater,
        can_reply_threads=algebra.greater,
        can_edit_threads=algebra.greater,
        can_edit_posts=algebra.greater,
        can_hide_threads=algebra.greater,
        can_hide_posts=algebra.greater,
        can_hide_own_threads=algebra.greater,
        can_hide_own_posts=algebra.greater,
        thread_edit_time=algebra.greater_or_zero,
        post_edit_time=algebra.greater_or_zero,
        can_protect_posts=algebra.greater,
        can_move_posts=algebra.greater,
        can_merge_posts=algebra.greater,
        can_change_threads_labels=algebra.greater,
        can_pin_threads=algebra.greater,
        can_close_threads=algebra.greater,
        can_move_threads=algebra.greater,
        can_merge_threads=algebra.greater,
        can_split_threads=algebra.greater,
        can_review_moderated_content=algebra.greater,
        can_report_content=algebra.greater,
        can_see_reports=algebra.greater,
        can_hide_events=algebra.greater,
    )

    return final_acl
开发者ID:Backenkoehler,项目名称:Misago,代码行数:59,代码来源:threads.py

示例5: add_acl_to_forum

def add_acl_to_forum(user, forum):
    forum_acl = user.acl['forums'].get(forum.pk, {})

    forum.acl.update({
        'can_see_all_threads': 0,
        'can_start_threads': 0,
        'can_reply_threads': 0,
        'can_edit_threads': 0,
        'can_edit_replies': 0,
        'can_hide_own_threads': 0,
        'can_hide_own_replies': 0,
        'thread_edit_time': 0,
        'reply_edit_time': 0,
        'can_hide_threads': 0,
        'can_hide_replies': 0,
        'can_protect_posts': 0,
        'can_change_threads_labels': 0,
        'can_change_threads_weight': 0,
        'can_close_threads': 0,
        'can_review_moderated_content': 0,
        'can_report_content': 0,
        'can_see_reports': 0,
    })

    algebra.sum_acls(forum.acl, acls=[forum_acl],
        can_see_all_threads=algebra.greater)

    if user.is_authenticated():
        algebra.sum_acls(forum.acl, acls=[forum_acl],
            can_start_threads=algebra.greater,
            can_reply_threads=algebra.greater,
            can_edit_threads=algebra.greater,
            can_edit_replies=algebra.greater,
            can_hide_threads=algebra.greater,
            can_hide_replies=algebra.greater,
            can_hide_own_threads=algebra.greater,
            can_hide_own_replies=algebra.greater,
            thread_edit_time=algebra.greater_or_zero,
            reply_edit_time=algebra.greater_or_zero,
            can_protect_posts=algebra.greater,
            can_change_threads_labels=algebra.greater,
            can_change_threads_weight=algebra.greater,
            can_close_threads=algebra.greater,
            can_review_moderated_content=algebra.greater,
            can_report_content=algebra.greater,
            can_see_reports=algebra.greater,
        )

    forum.acl['can_see_own_threads'] = not forum.acl['can_see_all_threads']
开发者ID:dahito,项目名称:Misago,代码行数:49,代码来源:permissions.py

示例6: build_acl

def build_acl(acl, roles, key_name):
    acl['can_see_unapproved_content_lists'] = False
    acl['can_see_reported_content_lists'] = False
    acl['can_approve_content'] = []
    acl['can_see_reports'] = []

    acl = algebra.sum_acls(acl, roles=roles, key=key_name,
        can_see_unapproved_content_lists=algebra.greater,
        can_see_reported_content_lists=algebra.greater
    )

    categories_roles = get_categories_roles(roles)
    categories = list(Category.objects.all_categories(include_root=True))

    approve_in_categories = []

    for category in categories:
        category_acl = acl['categories'].get(category.pk, {'can_browse': 0})
        if category_acl['can_browse']:
            category_acl = acl['categories'][category.pk] = build_category_acl(
                category_acl, category, categories_roles, key_name)

            if category_acl.get('can_see_reports'):
                acl['can_see_reports'].append(category.pk)
            if category_acl.get('can_approve_content'):
                approve_in_categories.append(category)

    return acl
开发者ID:h094071,项目名称:Misago,代码行数:28,代码来源:threads.py

示例7: build_acl

def build_acl(acl, roles, key_name):
    acl.update({
        'can_see_unapproved_content_lists': False,
        'can_see_reported_content_lists': False,
        'can_omit_flood_protection': False,
        'can_approve_content': [],
        'can_see_reports': [],
    })

    acl = algebra.sum_acls(acl, roles=roles, key=key_name,
        can_see_unapproved_content_lists=algebra.greater,
        can_see_reported_content_lists=algebra.greater,
        can_omit_flood_protection=algebra.greater
    )

    categories_roles = get_categories_roles(roles)
    categories = list(Category.objects.all_categories(include_root=True))

    for category in categories:
        category_acl = acl['categories'].get(category.pk, {'can_browse': 0})
        if category_acl['can_browse']:
            category_acl = acl['categories'][category.pk] = build_category_acl(
                category_acl, category, categories_roles, key_name)

            if category_acl.get('can_approve_content'):
                acl['can_approve_content'].append(category.pk)
            if category_acl.get('can_see_reports'):
                acl['can_see_reports'].append(category.pk)

    return acl
开发者ID:1905410,项目名称:Misago,代码行数:30,代码来源:threads.py

示例8: build_acl

def build_acl(acl, roles, key_name):
    new_acl = {
        'can_rename_users': 0,
        'can_moderate_avatars': 0,
        'can_moderate_signatures': 0,
        'can_moderate_profile_details': 0,
        'can_ban_users': 0,
        'max_ban_length': 2,
        'can_lift_bans': 0,
        'max_lifted_ban_length': 2,
    }
    new_acl.update(acl)

    return algebra.sum_acls(
        new_acl,
        roles=roles,
        key=key_name,
        can_rename_users=algebra.greater,
        can_moderate_avatars=algebra.greater,
        can_moderate_signatures=algebra.greater,
        can_moderate_profile_details=algebra.greater,
        can_ban_users=algebra.greater,
        max_ban_length=algebra.greater_or_zero,
        can_lift_bans=algebra.greater,
        max_lifted_ban_length=algebra.greater_or_zero,
    )
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:26,代码来源:moderation.py

示例9: build_acl

def build_acl(acl, roles, key_name):
    new_acl = {
        'can_browse_users_list': 0,
        'can_search_users': 0,
        'can_follow_users': 0,
        'can_be_blocked': 1,
        'can_see_users_name_history': 0,
        'can_see_ban_details': 0,
        'can_see_users_emails': 0,
        'can_see_users_ips': 0,
        'can_see_hidden_users': 0,
    }
    new_acl.update(acl)

    return algebra.sum_acls(new_acl, roles=roles, key=key_name,
        can_browse_users_list=algebra.greater,
        can_search_users=algebra.greater,
        can_follow_users=algebra.greater,
        can_be_blocked=algebra.lower,
        can_see_users_name_history=algebra.greater,
        can_see_ban_details=algebra.greater,
        can_see_users_emails=algebra.greater,
        can_see_users_ips=algebra.greater,
        can_see_hidden_users=algebra.greater
    )
开发者ID:1905410,项目名称:Misago,代码行数:25,代码来源:profiles.py

示例10: build_acl

def build_acl(acl, roles, key_name):
    new_acl = {
        'can_delete_users_newer_than': 0,
        'can_delete_users_with_less_posts_than': 0,
    }
    new_acl.update(acl)

    return algebra.sum_acls(new_acl, roles=roles, key=key_name,
        can_delete_users_newer_than=algebra.greater,
        can_delete_users_with_less_posts_than=algebra.greater
    )
开发者ID:Backenkoehler,项目名称:Misago,代码行数:11,代码来源:delete.py

示例11: build_acl

def build_acl(acl, roles, key_name):
    new_acl = {
        'max_attachment_size': 0,
        'can_download_other_users_attachments': False,
        'can_delete_other_users_attachments': False,
    }
    new_acl.update(acl)

    return algebra.sum_acls(new_acl, roles=roles, key=key_name,
        max_attachment_size=algebra.greater,
        can_download_other_users_attachments=algebra.greater,
        can_delete_other_users_attachments=algebra.greater
    )
开发者ID:1905410,项目名称:Misago,代码行数:13,代码来源:attachments.py

示例12: test_sum_acls

    def test_sum_acls(self):
        """acls are summed"""
        test_acls = [
            {
                'can_see': 0,
                'can_hear': 0,
                'max_speed': 10,
                'min_age': 16,
                'speed_limit': 50,
            },
            {
                'can_see': 1,
                'can_hear': 0,
                'max_speed': 40,
                'min_age': 20,
                'speed_limit': 0,
            },
            {
                'can_see': 0,
                'can_hear': 1,
                'max_speed': 80,
                'min_age': 18,
                'speed_limit': 40,
            },
        ]

        defaults = {
            'can_see': 0,
            'can_hear': 0,
            'max_speed': 30,
            'min_age': 18,
            'speed_limit': 60,
        }

        acl = algebra.sum_acls(
            defaults,
            acls=test_acls,
            can_see=algebra.greater,
            can_hear=algebra.greater,
            max_speed=algebra.greater,
            min_age=algebra.lower,
            speed_limit=algebra.greater_or_zero,
        )

        self.assertEqual(acl['can_see'], 1)
        self.assertEqual(acl['can_hear'], 1)
        self.assertEqual(acl['max_speed'], 80)
        self.assertEqual(acl['min_age'], 16)
        self.assertEqual(acl['speed_limit'], 0)
开发者ID:dasdsadadaddasa,项目名称:PythonScientists,代码行数:49,代码来源:test_acl_algebra.py

示例13: build_forum_acl

def build_forum_acl(acl, forum, forums_roles, key_name):
    if forum.level > 1:
        if forum.parent_id not in acl['visible_forums']:
            # dont bother with child forums of invisible parents
            return
        elif not acl['forums'][forum.parent_id]['can_browse']:
            # parent's visible, but its contents aint
            return

    forum_roles = forums_roles.get(forum.pk, [])

    final_acl = {
        'can_see': 0,
        'can_browse': 0,
    }

    algebra.sum_acls(final_acl, roles=forum_roles, key=key_name,
        can_see=algebra.greater,
        can_browse=algebra.greater
    )

    if final_acl['can_see']:
        acl['visible_forums'].append(forum.pk)
        acl['forums'][forum.pk] = final_acl
开发者ID:David1119,项目名称:Misago,代码行数:24,代码来源:permissions.py

示例14: build_acl

def build_acl(acl, roles, key_name):
    acl.update({
        'can_start_polls': 0,
        'can_edit_polls': 0,
        'can_delete_polls': 0,
        'poll_edit_time': 0,
        'can_always_see_poll_voters': 0
    })

    return algebra.sum_acls(acl, roles=roles, key=key_name,
        can_start_polls=algebra.greater,
        can_edit_polls=algebra.greater,
        can_delete_polls=algebra.greater,
        poll_edit_time=algebra.greater_or_zero,
        can_always_see_poll_voters=algebra.greater
    )
开发者ID:1905410,项目名称:Misago,代码行数:16,代码来源:polls.py

示例15: build_acl

def build_acl(acl, roles, key_name):
    new_acl = {
        'can_see_other_users_warnings': 0,
        'can_warn_users': 0,
        'can_cancel_warnings': 0,
        'can_delete_warnings': 0,
        'can_be_warned': 1,
    }
    new_acl.update(acl)

    return algebra.sum_acls(new_acl, roles=roles, key=key_name,
        can_see_other_users_warnings=algebra.greater,
        can_warn_users=algebra.greater,
        can_cancel_warnings=algebra.greater,
        can_delete_warnings=algebra.greater,
        can_be_warned=algebra.lower
    )
开发者ID:h094071,项目名称:Misago,代码行数:17,代码来源:warnings.py


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