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


Python Tree.static_collection_udfs_audit_ids方法代码示例

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


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

示例1: _plot_audits

# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import static_collection_udfs_audit_ids [as 别名]
def _plot_audits(user, instance, plot):
    fake_tree = Tree(instance=instance)
    tree_visible_fields = fake_tree.visible_fields(user)

    # Get a history of trees that were on this plot
    tree_history = plot.get_tree_history()

    tree_filter = Q(model='Tree',
                    field__in=tree_visible_fields,
                    model_id__in=tree_history)

    tree_delete_filter = Q(model='Tree',
                           action=Audit.Type.Delete,
                           model_id__in=tree_history)

    tree_collection_udfs_audit_names =\
        fake_tree.visible_collection_udfs_audit_names(user)

    tree_collection_udfs_filter = Q(
        model__in=tree_collection_udfs_audit_names,
        model_id__in=Tree.static_collection_udfs_audit_ids(
            (instance,), tree_history, tree_collection_udfs_audit_names))

    filters = [tree_filter, tree_delete_filter]
    cudf_filters = [tree_collection_udfs_filter]

    audits = _map_feature_audits(user, instance, plot, filters, cudf_filters)

    return audits
开发者ID:atogle,项目名称:OTM2,代码行数:31,代码来源:map_feature.py

示例2: _plot_audits

# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import static_collection_udfs_audit_ids [as 别名]
def _plot_audits(user, instance, plot):
    readable_plot_fields = plot.visible_fields(user)

    plot_filter = Q(model='Plot', model_id=plot.pk,
                    field__in=readable_plot_fields)

    plot_collection_udfs_filter = Q(
        model__in=plot.visible_collection_udfs_audit_names(user),
        model_id__in=plot.collection_udfs_audit_ids())

    fake_tree = Tree(instance=instance)
    tree_visible_fields = fake_tree.visible_fields(user)

    # Get a history of trees that were on this plot
    tree_history = plot.get_tree_history()

    tree_filter = Q(model='Tree',
                    field__in=tree_visible_fields,
                    model_id__in=tree_history)

    tree_delete_filter = Q(model='Tree',
                           action=Audit.Type.Delete,
                           model_id__in=tree_history)

    tree_collection_udfs_audit_names =\
        fake_tree.visible_collection_udfs_audit_names(user)

    tree_collection_udfs_filter = Q(
        model__in=tree_collection_udfs_audit_names,
        model_id__in=Tree.static_collection_udfs_audit_ids(
            (instance,), tree_history, tree_collection_udfs_audit_names))

    # Seems to be much faster to do three smaller
    # queries here instead of ORing them together
    # (about a 50% inprovement!)
    # TODO: Verify this is still the case now that we are also getting
    # collection udf audits
    iaudit = Audit.objects.filter(instance=instance)

    audits = []
    for afilter in [tree_filter, tree_delete_filter, plot_filter]:
        audits += list(iaudit.filter(afilter).order_by('-updated')[:5])

    # UDF collection audits have some fields which aren't very useful to show
    udf_collection_exclude_filter = Q(
        field__in=['model_id', 'field_definition'])

    for afilter in [plot_collection_udfs_filter, tree_collection_udfs_filter]:
        audits += list(iaudit.filter(afilter)
                             .exclude(udf_collection_exclude_filter)
                             .order_by('-updated')[:5])

    audits = sorted(audits, key=lambda audit: audit.updated, reverse=True)[:5]

    return audits
开发者ID:heath,项目名称:OTM2,代码行数:57,代码来源:views.py


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