def insert_visit_record(baby_id, measure_date, weight, height, head, court_id, brand_id, breastfeeding, kind, nutrition, add_type): """ 新增随访记录 """ common = 0 week = 0 try: temp = measure_date temp = temp.replace('-','') common = temp[:6] week = check_is_week(week, baby_id, measure_date) except: pass if add_type: tracking = Tracking(baby_id=baby_id, measure_date=measure_date, weight=weight, height=height, head_wai=head, court_id=court_id, brand_id=brand_id, breast_milk_amount=breastfeeding, type_of_milk_id=kind, formula_feed_measure=nutrition, add_type=add_type, common=common, week=week) else: tracking = Tracking(baby_id=baby_id, measure_date=measure_date, weight=weight, height=height, head_wai=head, court_id=court_id, brand_id=brand_id, breast_milk_amount=breastfeeding, type_of_milk_id=kind, formula_feed_measure=nutrition, common=common, week=week) try: db.add(tracking) db.commit() except: return False return True
def by_id_alter_password(user_id, old_password, new_password, type): """ 通过user_id来获取信息 判断old_password是否正确 修改密码 """ entrance = get_session('entrance') if type == 'baby': baby = Baby.query.filter(Baby.id == user_id).first() if baby: if baby.baby_pass == old_password: baby.baby_pass = new_password try: db.commit() except: return False return True else: return False elif type is None or type == 'doctor': doctor = Doctor.query.filter(Doctor.id == user_id).first() if doctor: if doctor.doctor_pass == old_password: doctor.doctor_pass = new_password try: db.commit() except: return False return True else: return False