def update_dog(dog_id): dog = models.get_dog(dog_id) if len(dog) == 0: abort(404) if not request.json: abort(400) if 'name' in request.json and type(request.json['name']) is not unicode: abort(400) if 'description' in request.json and type(request.json['description']) is not unicode: abort(400) if 'registration_id' in request.json and type(request.json['registration_id']) is not unicode: abort(400) if 'handler_id' in request.json and type(request.json['handler_id']) is not unicode: abort(400) if 'reg_status' in request.json and type(request.json['reg_status']) is not bool: abort(400) if 'vacc_status' in request.json and type(request.json['vacc_status']) is not bool: abort(400) if 'pedigree' in request.json and type(request.json['pedigree']) is not unicode: abort(400) dog['name'] = request.json.get('name', dog['name']) dog['registration_id'] = request.json.get('registration_id', dog['registration_id']) dog['description'] = request.json.get('description', dog['description']) dog['handler_id'] = request.json.get('handler_id', dog['handler_id']) dog['reg_status'] = request.json.get('reg_status', dog['reg_status']) dog['vacc_status'] = request.json.get('vacc_status', dog['vacc_status']) models.update_dog(dog) return jsonify( { 'dog': dog } )
def get_dog(dog_id): dog = models.get_dog(dog_id) if not dog: # No dog with that id found abort(404) return jsonify( { 'dog': dog })
def delete_dog(dog_id): dog = models.get_dog(dog_id) if dog is None: abort(404) models.delete_dog(dog_id) return jsonify( { 'result': True } )