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