def input(self, name="", sex=0, birthday="", class_id="", status="apply", relation_number=3, describe=""): if birthday and not convert.is_date(birthday): raise exception.FormalError(birthday=birthday) if not name: raise exception.ParamNone(name="") if not class_id: raise exception.ParamNone(name="") class_info = db_api.class_get(id=class_id) if not class_info: raise exception.NotFound(code=class_id) values = { "name": name, "sex": sex, #"birthday": birthday, "school_id": class_info.school_id, "grade_id": class_info.grade_id, "class_id": class_id, "describe": describe, #"status": status, "relation_number": relation_number } if birthday: values.update({"birthday": birthday}) student_obj = db_api.student_create(values) if student_obj: history_values={ "student_id": student_obj.get("id"), "staus": status } db_api.student_history_create(history_values) student_obj.update({"status": status}) return student_obj
def combination_delete(self, id=""): if not id: return "id is none" db_combination.delete_student(student_id=id) history_values = { "student_id": id, "status": "deleted" } db_api.student_history_create(history_values)
def delete(self, id="", **kwargs): if not id: return "id is none" _relation_count = db_api.relation_count(student_id=id) if _relation_count > 0: return "exist relation" db_api.student_deleted(id=id) history_values={ "student_id": id, "status": "deleted" } db_api.student_history_create(history_values)
def update(self, id="", **kwargs): if not id or not kwargs: raise exception.ParamNone(id=id) if kwargs.get("class_id"): class_info = db_api.class_get(id=kwargs.get("class_id")) kwargs.update({ "school_id": class_info.school_id, "grade_id": class_info.grade_id, }) status = kwargs.pop("status", "") _ = db_api.student_update(id, kwargs) if status: history_values = { "student_id": id, "staus": status } db_api.student_history_create(history_values) return _
def input(self, student_id, status, describe=""): if not student_id or not status: LOG.error("student_id name or status is None") return if not db_api.student_get(id=student_id): return values = { "student_id": student_id, "status": status, "describe": describe } _ = db_api.student_history_create(values) return values