示例#1
0
 def delete(id):
     entity = Vehicle.get(id)
     if (entity is None):
         raise ValueError("Vehicle does not exists")
     else:
         entity.active = False
         Vehicle.save(entity)
示例#2
0
 def save(entity):
     if entity.key is None:
         entity = Vehicle.save(entity)
     else:
         current = Vehicle.get(entity.key.urlsafe())
         if current is not None:
             current.vehicle_name = entity.vehicle_name
             current.company_key = entity.company_key
             current.driver_key = entity.driver_key
             current.model = entity.model
             current.size = entity.size
             current.tag_number = entity.tag_number
             current.active = entity.active
             entity = Vehicle.save(entity)
         else:
             raise ValueError("Vehicle does not exists")
     return entity
示例#3
0
def update_entry(auto_id):
    try:
        validate(bottle.request.forms)
    except IntegrityError:
        return { "success": False, "error": "Update rejected." }

    try:
        item = Vehicle.get(Vehicle.id == auto_id)
    except DoesNotExist:
        return { "success": False, "error": "Item not found." }

    for key, value in bottle.request.forms.items():
        setattr(item, key, value)
    photo = bottle.request.files.get('photo')
    if photo:
        item.photo = photo.file.read()
    item.save()
    return { "success": True, "data": parse(item) }
示例#4
0
def delete_entry(auto_id):
    Vehicle.get(Vehicle.id == auto_id).delete_instance()
    return { "success": True }
示例#5
0
def retrieve_entry(auto_id):
    data = parse(Vehicle.get(Vehicle.id == auto_id))
    return { "success": True, "data": data }
示例#6
0
 def get(id):
     return Vehicle.get(id)