本文整理汇总了Python中treemap.lib.map_feature.get_map_feature_or_404函数的典型用法代码示例。如果您正苦于以下问题:Python get_map_feature_or_404函数的具体用法?Python get_map_feature_or_404怎么用?Python get_map_feature_or_404使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_map_feature_or_404函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _add_map_feature_photo_helper
def _add_map_feature_photo_helper(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
data = get_image_from_request(request)
photo = feature.add_photo(data, request.user)
# We must update a rev so that missing photo searches are up to date
instance.update_universal_rev()
return photo
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:7,代码来源:map_feature.py
示例2: delete_map_feature
def delete_map_feature(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
if not map_feature_is_deletable(request.user.get_instance_user(instance), feature):
raise ValidationError("map feature not deletable")
feature.delete_with_user(request.user)
update_hide_at_zoom_after_delete(feature)
return {"ok": True}
开发者ID:RobinIsTheBird,项目名称:otm-core,代码行数:7,代码来源:map_feature.py
示例3: add_tree_photo_helper
def add_tree_photo_helper(request, instance, feature_id, tree_id=None):
plot = get_map_feature_or_404(feature_id, instance, 'Plot')
tree_ids = [t.pk for t in plot.tree_set.all()]
if tree_id and int(tree_id) in tree_ids:
tree = Tree.objects.get(pk=tree_id)
elif tree_id is None:
# See if a tree already exists on this plot
tree = plot.current_tree()
if tree is None:
# A tree doesn't exist, create a new tree create a
# new tree, and attach it to this plot
tree = Tree(plot=plot, instance=instance)
# TODO: it is possible that a user has the ability to
# 'create tree photos' but not trees. In this case we
# raise an authorization exception here.
# It is, however, possible to have both a pending
# tree and a pending tree photo
# This will be added later, when auth/admin work
# correctly with this system
tree.save_with_user(request.user)
else:
# Tree id is invalid or not in this plot
raise Http404('Tree id %s not found on plot %s'
% (tree_id, feature_id))
#TODO: Auth Error
data = get_image_from_request(request)
treephoto = tree.add_photo(data, request.user)
return treephoto, tree
开发者ID:HackMichiana,项目名称:otm-core,代码行数:34,代码来源:tree.py
示例4: map_feature_popup
def map_feature_popup(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
context = context_dict_for_map_feature(request, feature)
if instance.canopy_enabled:
context['boundaries_with_canopy'] = \
_get_boundaries_with_canopy(instance, feature.geom)
return context
开发者ID:RickMohr,项目名称:otm-core,代码行数:7,代码来源:map_feature.py
示例5: delete_map_feature
def delete_map_feature(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
if not map_feature_is_deletable(request.user.get_instance_user(instance),
feature):
raise ValidationError("map feature not deletable")
feature.delete_with_user(request.user)
return {'ok': True}
开发者ID:recklessromeo,项目名称:otm-core,代码行数:7,代码来源:map_feature.py
示例6: delete_map_feature
def delete_map_feature(request, instance, feature_id, type='Plot'):
feature = get_map_feature_or_404(feature_id, instance, type)
try:
feature.delete_with_user(request.user)
return {'ok': True}
except ValidationError as ve:
return "; ".join(ve.messages)
开发者ID:cgarrard,项目名称:OTM2,代码行数:7,代码来源:map_feature.py
示例7: map_feature_popup
def map_feature_popup(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
context = {}
context['features'] = [feature] + list(feature.nearby_map_features())
if instance.canopy_enabled:
context['boundaries_with_canopy'] = \
_get_boundaries_with_canopy(instance, feature.geom)
return context
开发者ID:OpenTreeMap,项目名称:otm-core,代码行数:8,代码来源:map_feature.py
示例8: wrapper
def wrapper(request, instance, feature_id, *args, **kwargs):
error = None
try:
fn(request, instance, feature_id, *args, **kwargs)
except ValidationError as e:
error = "; ".join(e.messages)
feature = get_map_feature_or_404(feature_id, instance)
photos = feature.photos()
return {"photos": [context_dict_for_photo(request, photo) for photo in photos], "error": error}
开发者ID:RobinIsTheBird,项目名称:otm-core,代码行数:9,代码来源:map_feature.py
示例9: add_map_feature_photo
def add_map_feature_photo(request, instance, feature_id):
error = None
try:
_add_map_feature_photo_helper(request, instance, feature_id)
except ValidationError as e:
error = '; '.join(e.messages)
feature = get_map_feature_or_404(feature_id, instance)
photos = feature.photos()
return {'photos': map(context_dict_for_photo, photos),
'error': error}
开发者ID:cgarrard,项目名称:OTM2,代码行数:10,代码来源:map_feature.py
示例10: wrapper
def wrapper(request, instance, feature_id, *args, **kwargs):
error = None
try:
fn(request, instance, feature_id, *args, **kwargs)
except ValidationError as e:
error = '; '.join(e.messages)
feature = get_map_feature_or_404(feature_id, instance)
photos = feature.photos()
return {'photos': map(context_dict_for_photo, photos),
'error': error}
开发者ID:ctaylo37,项目名称:OTM2,代码行数:10,代码来源:map_feature.py
示例11: rotate_map_feature_photo
def rotate_map_feature_photo(request, instance, feature_id, photo_id):
orientation = request.REQUEST.get("degrees", None)
if orientation not in {"90", "180", "270", "-90", "-180", "-270"}:
raise ValidationError('"degrees" must be a multiple of 90°')
degrees = int(orientation)
feature = get_map_feature_or_404(feature_id, instance)
mf_photo = get_object_or_404(MapFeaturePhoto, pk=photo_id, map_feature=feature)
image_data = mf_photo.image.read(settings.MAXIMUM_IMAGE_SIZE)
mf_photo.set_image(image_data, degrees_to_rotate=degrees)
mf_photo.save_with_user(request.user)
开发者ID:RobinIsTheBird,项目名称:otm-core,代码行数:12,代码来源:map_feature.py
示例12: _map_feature_detail_context
def _map_feature_detail_context(request, instance, feature_id, edit=False):
feature = get_map_feature_or_404(feature_id, instance)
ctx_fn = (context_dict_for_plot if feature.is_plot
else context_dict_for_resource)
context = ctx_fn(request, feature, edit=edit)
if feature.is_plot:
partial = 'treemap/partials/plot_detail.html'
else:
app = feature.__module__.split('.')[0]
partial = '%s/%s_detail.html' % (app, feature.feature_type)
return context, partial
开发者ID:RickMohr,项目名称:otm-core,代码行数:13,代码来源:map_feature.py
示例13: map_feature_hash
def map_feature_hash(request, instance, feature_id, edit=False, tree_id=None):
"""
Compute a unique hash for a given plot or tree
tree_id is ignored since trees are included as a
subset of the plot's hash. It is present here because
this function is wrapped around views that can take
tree_id as an argument
"""
feature = get_map_feature_or_404(feature_id, instance)
if request.user:
pk = request.user.pk or ''
return hashlib.md5(feature.hash + ':' + str(pk)).hexdigest()
开发者ID:RickMohr,项目名称:otm-core,代码行数:15,代码来源:map_feature.py
示例14: map_feature_detail
def map_feature_detail(request, instance, feature_id, render=False, edit=False):
feature = get_map_feature_or_404(feature_id, instance)
ctx_fn = context_dict_for_plot if feature.is_plot else context_dict_for_resource
context = ctx_fn(request, feature, edit=edit)
add_map_info_to_context(context, instance)
if render:
if feature.is_plot:
template = "treemap/plot_detail.html"
else:
app = feature.__module__.split(".")[0]
template = "%s/%s_detail.html" % (app, feature.feature_type)
return render_to_response(template, context, RequestContext(request))
else:
return context
开发者ID:jwalgran,项目名称:otm-core,代码行数:16,代码来源:map_feature.py
示例15: map_feature_detail
def map_feature_detail(request, instance, feature_id,
render=False, edit=False):
feature = get_map_feature_or_404(feature_id, instance)
ctx_fn = (context_dict_for_plot if feature.is_plot
else context_dict_for_resource)
context = ctx_fn(request, feature, edit=edit)
add_map_info_to_context(context, instance)
if render:
if feature.is_plot:
template = 'treemap/plot_detail.html'
else:
app = feature.__module__.split('.')[0]
try:
template = '%s/%s_detail.html' % (app, feature.feature_type)
get_template(template)
except TemplateDoesNotExist:
template = 'treemap/resource_detail.html'
return render_to_response(template, context,
RequestContext(request))
else:
return context
开发者ID:recklessromeo,项目名称:otm-core,代码行数:23,代码来源:map_feature.py
示例16: _add_map_feature_photo_helper
def _add_map_feature_photo_helper(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
data = get_image_from_request(request)
return feature.add_photo(data, request.user)
开发者ID:RickMohr,项目名称:otm-core,代码行数:4,代码来源:map_feature.py
示例17: unfavorite_map_feature
def unfavorite_map_feature(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
Favorite.objects.filter(user=request.user, map_feature=feature).delete()
return {'success': True}
开发者ID:RickMohr,项目名称:otm-core,代码行数:5,代码来源:map_feature.py
示例18: favorite_map_feature
def favorite_map_feature(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
Favorite.objects.get_or_create(user=request.user, map_feature=feature)
return {'success': True}
开发者ID:RickMohr,项目名称:otm-core,代码行数:5,代码来源:map_feature.py
示例19: delete_map_feature
def delete_map_feature(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
feature.delete_with_user(request.user) # may raise AuthorizeException
update_hide_at_zoom_after_delete(feature)
return {'ok': True}
开发者ID:RickMohr,项目名称:otm-core,代码行数:5,代码来源:map_feature.py
示例20: update_map_feature_detail
def update_map_feature_detail(request, instance, feature_id):
feature = get_map_feature_or_404(feature_id, instance)
return _request_to_update_map_feature(request, feature)
开发者ID:RickMohr,项目名称:otm-core,代码行数:3,代码来源:map_feature.py
注:本文中的treemap.lib.map_feature.get_map_feature_or_404函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论