def show(location_id): schema = LocationSchema() location = Location.get(id=location_id) if not location: abort(404) return schema.dumps(location)
def delete(location_id): location = Location.get(id=location_id) if not location: abort(404) location.delete() db.commit() return '', 204
def update(location_id): schema = LocationSchema() location = Location.get(id=location_id) if not location: abort(404) try: data = schema.load(request.get_json()) location.set(**data) db.commit() except ValidationError as err: return jsonify({ 'message': 'Validation failed', 'errors': err.messages }), 422 return schema.dumps(location)