Example #1
0
def post_data(visualization_id, request):
    """Post new data for an existing visualization (i.e. add data to existing
    object in db).

    Arguments:
    visualization_id -- id of the visualization for which the data posted is.
    request          -- Flask request object, with the data for the 
                        visualization in the json field.
    """
    data = request.json
    result = db.write_viz_data(visualization_id, data)
    # TODO: return proper value to describe succes/failure of data write.
    return {"empty": result}
Example #2
0
def post_data(visualization_id, request):
    """Post new data for an existing visualization (i.e. add data to existing
    object in db).

    Arguments:
    visualization_id -- id of the visualization for which the data posted is.
    request          -- Flask request object, with the data for the 
                        visualization in the json field.
    """
    data = request.json
    result = db.write_viz_data(visualization_id, data)
    # TODO: return proper value to describe succes/failure of data write.
    return {"empty": result}
Example #3
0
def post_data_new_viz(request):
    """Post new data for a new visualization (i.e. we don't know the id, so 
    create some new visualization object to hold this data). The method should
    return the _id of the visualization created.

    Arguments:
    request --  Flask request object, with the data for the visualization
                in the json field.
    """
    # check if any name has been provided for the visualization, otherwise
    # generate a random one.
    data = request.get_json()
    print type(data)
    print data
    if not 'name' in data:
        data.name = uuid.uuid4()

    # generate the viz id.
    data['_id'] = uuid.uuid4().hex

    # write the new object to db.
    result = db.write_viz_data(data['_id'], data)
    return result
Example #4
0
def post_data_new_viz(request):
    """Post new data for a new visualization (i.e. we don't know the id, so 
    create some new visualization object to hold this data). The method should
    return the _id of the visualization created.

    Arguments:
    request --  Flask request object, with the data for the visualization
                in the json field.
    """
    # check if any name has been provided for the visualization, otherwise 
    # generate a random one.
    data = request.get_json()
    print type(data)
    print data
    if not 'name' in data:
        data.name = uuid.uuid4()

    # generate the viz id.
    data['_id'] = uuid.uuid4().hex

    # write the new object to db.
    result = db.write_viz_data(data['_id'], data)
    return result