本文整理汇总了Python中treemap.lib.map_feature.context_dict_for_plot函数的典型用法代码示例。如果您正苦于以下问题:Python context_dict_for_plot函数的具体用法?Python context_dict_for_plot怎么用?Python context_dict_for_plot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了context_dict_for_plot函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: edits
def edits(request, instance, user_id):
if (int(user_id) != request.user.pk):
return create_401unauthorized()
user = request.user
result_offset = int(request.REQUEST.get("offset", 0))
num_results = min(int(request.REQUEST.get("length", 15)), 15)
audits = Audit.objects.filter(instance=instance)\
.filter(user=user)\
.filter(model_in=['Tree', 'Plot'])\
.order_by('-created', 'id')
audits = audits[result_offset:(result_offset+num_results)]
keys = []
for audit in audits:
d = {}
plot = extract_plot_from_audit(audit)
d["plot_id"] = plot.pk
if plot.pk:
d["plot"] = context_dict_for_plot(request, plot)
d["id"] = audit.pk
d["name"] = audit.display_action
d["created"] = datetime_to_iso_string(audit.created)
d["value"] = audit.current_value
keys.append(d)
return keys
开发者ID:summer-of-open-source,项目名称:OTM2,代码行数:33,代码来源:views.py
示例2: update_or_create_plot
def update_or_create_plot(request, instance, plot_id=None):
# The API communicates via nested dictionaries but
# our internal functions prefer dotted pairs (which
# is what inline edit form users)
request_dict = json.loads(request.body)
data = {}
for model in ["plot", "tree"]:
if model in request_dict:
for key, val in request_dict[model].iteritems():
data["%s.%s" % (model, key)] = val
# We explicitly disallow setting a plot's tree id.
# We ignore plot's updated at and by because
# auditing sets them automatically.
keys = ["tree.plot",
"tree.udfs",
"tree.instance",
"plot.updated_at",
"plot.updated_by",
"plot.instance",
"plot.udfs"]
for key in keys:
if key in data:
del data[key]
if "tree.species" in data:
sp = data["tree.species"]
if sp and "id" in sp:
data["tree.species"] = sp['id']
else:
data["tree.species"] = None
if plot_id:
plot = get_object_or_404(Plot, pk=plot_id, instance=instance)
else:
plot = Plot(instance=instance)
plot, __ = update_map_feature(data, request.user, plot)
context_dict = context_dict_for_plot(request, plot)
# Add geo rev hash so clients will know if a tile refresh is required
context_dict["geoRevHash"] = plot.instance.geo_rev_hash
context_dict["universalRevHash"] = plot.instance.universal_rev_hash
return context_dict
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:49,代码来源:plots.py
示例3: _approve_or_reject_pending_edit
def _approve_or_reject_pending_edit(
request, instance, user, pending_edit_id, approve):
audit = Audit.objects.get(pk=pending_edit_id, instance=instance)
approve_or_reject_audit_and_apply(audit, user, approve)
updated_plot = extract_plot_from_audit(audit)
# Reject remaining audits on specified field if
# we approved this audit
# TODO: Should this logic be moved to app_or_rej_audit_and_ap?
if approve:
for pending_audit in updated_plot.get_active_pending_audits()\
.filter(field=audit.field):
approve_or_reject_audit_and_apply(pending_audit, user, False)
return context_dict_for_plot(request, updated_plot)
开发者ID:summer-of-open-source,项目名称:OTM2,代码行数:16,代码来源:views.py
示例4: remove_current_tree_from_plot
def remove_current_tree_from_plot(request, instance, plot_id):
plot = get_object_or_404(Plot, pk=plot_id, instance=instance)
tree = plot.current_tree()
if tree:
try:
tree.delete_with_user(request.user)
updated_plot = Plot.objects.get(pk=plot_id)
return context_dict_for_plot(request, updated_plot)
except:
raise PermissionDenied(
'%s does not have permission to the '
'current tree from plot %s' %
(request.user.username, plot_id))
else:
raise HttpResponseBadRequest(
"Plot %s does not have a current tree" % plot_id)
开发者ID:summer-of-open-source,项目名称:OTM2,代码行数:17,代码来源:views.py
示例5: get_plot
def get_plot(request, instance, plot_id):
return context_dict_for_plot(request, Plot.objects.get(pk=plot_id))
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:2,代码来源:plots.py
示例6: ctxt_for_plot
def ctxt_for_plot(plot):
return context_dict_for_plot(request, plot)
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:2,代码来源:plots.py
示例7: plot_detail
def plot_detail(request, instance, feature_id, edit=False, tree_id=None):
feature = get_map_feature_or_404(feature_id, instance, 'Plot')
return context_dict_for_plot(request, feature, edit=edit, tree_id=tree_id)
开发者ID:RickMohr,项目名称:otm-core,代码行数:3,代码来源:map_feature.py
注:本文中的treemap.lib.map_feature.context_dict_for_plot函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论