Ejemplo n.º 1
0
def get_all_images():
    db = DataAccessImage()
    images_from_DB = db.get_all_images()
    logger.info('In FUNCTION %s list of all images returned from DB: %s\n',
                'get_all_images', images_from_DB)
    for image in images_from_DB:
        image['path'] = ConfigProvider.PHOTOS_BASE_URL + image['name']
    resp = make_response(jsonify(images_from_DB))
    return resp
Ejemplo n.º 2
0
def delete_link(imageID):
    ensure_admin()
    data = json.loads(request.stream.read())
    db = DataAccessImage()
    link_handler = ImageLinkerHandler(db)
    link = ImageLinker(data["origin"], data["destination"], data["latitude"],
                       data["longitude"])
    return jsonify(link_handler.delete_link(link))
Ejemplo n.º 3
0
def update_image():
    ensure_admin()
    data = json.loads(request.stream.read())
    db = DataAccessImage()
    image_handler = ImageHandler(db)
    image = Image(data["id"], data["name"], data["imageType"],
                  data["eventType"], data["location"])
    return jsonify(image_handler.edit_image(image))
Ejemplo n.º 4
0
def delete_image():
    ensure_admin()
    data = json.loads(request.stream.read())
    db = DataAccessImage()
    image_handler = ImageHandler(db)
    res = image_handler.delete_image(data["id"])
    try:
        if res:
            return make_response(jsonify(res), 204)
        else:
            return make_response(jsonify(res), 400)
    except:
        return make_response("Something went wrong", 400)
Ejemplo n.º 5
0
def add_location():
    ensure_admin()
    data = json.loads(request.stream.read())
    location = Location(data["name"],data["type"],data["latitude"],data["longitude"], data["description"] )
    loc_DB = DataAccessLocation()
    loc_handler = LocationHandler(loc_DB)
    loc_handler.add_location(location) 
    logger.info('In FUNCTION %s data of new location  that need to be added to Db: %s\n', 'add_location', data)
    image = Image(data["id"], data["sphereImageList"][0]['name'], "sphere", data["type"], data["name"])
    im_DB = DataAccessImage()
    im_handler = ImageHandler(im_DB)
    im_handler.add_image(image)
    return '200'
Ejemplo n.º 6
0
def get_links(imageName):
    # data = json.loads(request.stream.read(
    db = DataAccessImage()
    link_handler = ImageLinkerHandler(db)
    return jsonify(link_handler.get_links_for_image(imageName))