예제 #1
0
def _get_layer_to_dict_json(app_id, layer_id):
    layer = Layer.get_by_id(int(layer_id))

    if layer is None or layer.app_id != app_id:
        raise MSException('LayerId invalido')

    return layer.to_dict_json()
예제 #2
0
def save(app_data, form):
    validate(form, RULES)
    form = _fix(form)
    if 'id' in form:
        layer = Layer.get_by_id(int(form['id']))
        if layer is None:
            raise MSException('layerId invalido')
        layer.name = form.get('name', layer.name)
        layer.latitude = form.get('latitude', layer.latitude)
        layer.longitude = form.get('longitude', layer.longitude)
        layer.radius = form.get('radius', layer.radius)
        layer.put()
    else:
        layer_key = Layer.save(app_data['app']['id'], form)
        layer = layer_key.get()
    return layer.to_dict_json()
예제 #3
0
def save(app_data, form):
    validate(form, RULES)
    form = _fix(form)
    if 'id' in form:
        layer = Layer.get_by_id(int(form['id']))
        if layer is None:
            raise MSException('layerId invalido')
        layer.name = form.get('name', layer.name)
        layer.latitude = form.get('latitude', layer.latitude)
        layer.longitude = form.get('longitude', layer.longitude)
        layer.radius = form.get('radius', layer.radius)
        layer.put()
    else:
        layer_key = Layer.save(app_data['app']['id'], form)
        layer = layer_key.get()
    return layer.to_dict_json()
예제 #4
0
def save(app_data, layer_id, field_storage):
    layer = Layer.get_by_id(int(layer_id))

    if layer is None:
        raise MSException(u'LayerId inválido')

    file_type = _get_file_type(field_storage)
    if file_type == IMAGE:
        _s3_save(field_storage)
        instance = _get_image_instance(field_storage)
    else:
        raise MSException(u'Tipo de arquivo invalido, verifique se ele é: %s' % ', '.join(img_exts))

    instance.layer = layer.key
    instance.app_id = app_data['app']['id']
    instance.put()

    return instance.to_dict_json()
예제 #5
0
def save(app_data, layer_id, field_storage):
    layer = Layer.get_by_id(int(layer_id))

    if layer is None:
        raise MSException(u'LayerId inválido')

    file_type = _get_file_type(field_storage)
    if file_type == IMAGE:
        _s3_save(field_storage)
        instance = _get_image_instance(field_storage)
    else:
        raise MSException(u'Tipo de arquivo invalido, verifique se ele é: %s' %
                          ', '.join(img_exts))

    instance.layer = layer.key
    instance.app_id = app_data['app']['id']
    instance.put()

    return instance.to_dict_json()
예제 #6
0
def delete(app_data, layer_id, options):
    """
        options:
            delete_cascade = [true | false]
    """
    result = {}
    layer = Layer.get_by_id(layer_id)

    if layer is None or layer.app_id != app_data['app']['id']:
        raise MSException('LayerId invalido')

    if layer.deleted:
        raise MSException('Layer ja foi deletado')

    if options.get('delete_cascade', False):
        result['files'] = _delete_files(layer)

    layer.deleted = True
    layer.put()

    result['layer'] = layer.to_dict_json()
    return result