

@contextfunction
def permission_block(context, object):
    'Block with objects permissions'
    request = context['request']
    response_format = 'html'
    if ('response_format' in context):
        response_format = context['response_format']
    response_format_tags = response_format
    if ('response_format_tags' in context):
        response_format_tags = context['response_format_tags']
    if ('permission' in request.GET):
        if request.user.profile.has_permission(object, mode='w'):
            if request.POST:
                if ('cancel' in request.POST):
                    request.redirect = request.path
                    return Markup(render_to_string('core/tags/permission_block', {
                        'object': object,
                        'path': request.path,
                    }, context_instance=RequestContext(request), response_format=response_format))
                form = PermissionForm(request.POST, instance=object)
                if form.is_valid():
                    form.save()
                    request.redirect = request.path
                    return Markup(render_to_string('core/tags/permission_block', {
                        'object': object,
                        'path': request.path,
                    }, context_instance=RequestContext(request), response_format=response_format))
            else:
                form = PermissionForm(instance=object)
            context = {
                'object': object,
                'path': request.path,
                'form': form,
            }
            if ('ajax' in response_format_tags):
                context = converter.preprocess_context(context)
            return Markup(render_to_string('core/tags/permission_block_edit', context, context_instance=RequestContext(request), response_format=response_format))
    return Markup(render_to_string('core/tags/permission_block', {
        'object': object,
        'path': request.path,
    }, context_instance=RequestContext(request), response_format=response_format))

dataset/ETHPy150Open treeio/treeio/treeio/core/templatetags/object.py permission_block/original