@contextfunction
def attachments_block(context, object=None):
    "Attachments for an object or update record"

    request = context['request']

    response_format = 'html'
    if 'response_format' in context:
        response_format = context['response_format']

    update = isinstance(object, UpdateRecord)

    if not update:
        attachments = Attachment.objects.filter(attached_object=object)
        template = 'core/tags/attachments_block'
    else:
        attachments = Attachment.objects.filter(attached_record=object)
        template = 'core/tags/attachments_record_block'

    return Markup(render_to_string(template,
                                   {'object': object,
                                    'attachments': attachments,
                                    },
                                   context_instance=RequestContext(request),
                                   response_format=response_format))
dataset/ETHPy150Open treeio/treeio/treeio/core/templatetags/object.py/attachments_block/original