def create_alert(cats_id): """ Create an alert """ try: if len(storage.getobject(CategorySub, "id", cats_id)) == 0: return jsonify({"Error": "CategorySub id not found"}) data = request.get_json(force=True) for at in attr: if at not in data.keys(): return jsonify({"Error": "Missing " + at}) new_obj = Alert() set_obj(new_obj, **data) new_obj.low = (new_obj.middle - 1) new_obj.CategorySub_id = cats_id storage.insert(new_obj) return jsonify(new_obj.to_dict()) except Exception: abort(404)