def handle_post_metadata(request, collection, success_message):
    metadata = json.loads(request.body)

    try:
        metadata_list = save_metadata(collection, metadata)
    except __HOLE__ as e:
        return error_response(e)

    messages.success(request,
                     success_message,
                     extra_tags='alert-success')

    return {'data': metadata_list, 'status': 200}
dataset/ETHPy150Open NeuroVault/NeuroVault/neurovault/apps/statmaps/image_metadata.py/handle_post_metadata