def delete(id): entity = Vehicle.get(id) if (entity is None): raise ValueError("Vehicle does not exists") else: entity.active = False Vehicle.save(entity)
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
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) }
def delete_entry(auto_id): Vehicle.get(Vehicle.id == auto_id).delete_instance() return { "success": True }
def retrieve_entry(auto_id): data = parse(Vehicle.get(Vehicle.id == auto_id)) return { "success": True, "data": data }
def get(id): return Vehicle.get(id)