本文整理汇总了Python中treemap.models.Tree.visible_fields方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.visible_fields方法的具体用法?Python Tree.visible_fields怎么用?Python Tree.visible_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treemap.models.Tree
的用法示例。
在下文中一共展示了Tree.visible_fields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _plot_audits
# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import visible_fields [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
示例2: _plot_audits
# 需要导入模块: from treemap.models import Tree [as 别名]
# 或者: from treemap.models.Tree import visible_fields [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