Exemple #1
0
    def post():
        parser = reqparse.RequestParser()
        parser.add_argument('user_id', type=str, required=False, help=u'user_id 必须')
        parser.add_argument('old_password', type=str, required=True, help=u'old_password 必须')
        parser.add_argument('new_password', type=str, required=True, help=u'new_password 必须')
        parser.add_argument('type', type=str, required=False, help=u'type 必须')

        args = parser.parse_args()

        old_password = args['old_password']
        new_password = args['new_password']
        user_id = get_session('user_id')
        type = get_session('type')

        return_success = success_dic().dic
        return_fail = fail_dic().dic
        # user_id = get_session('user_id')
        if user_id is None:
            return_fail.pop('message')
            return_fail['msg'] = '请先登录!'
            return_fail.pop('code')
            return_fail['code'] = 404
            return return_fail

        is_true = by_id_alter_password(user_id, old_password, new_password, type)
        if is_true:
            return_success['message'] = '修改密码成功'
            return return_success
        else:
            return_success['message'] = '旧密码不正确'
            return return_success
Exemple #2
0
def to_grow_bar(baby_id):
    analysis = get_analysis_data(baby_id)
    breastfeeding, formula_feeding, grow_time  = get_tracking_bar(baby_id, None)
    return render_template('baby/grow_bar.html',
                           user_id=get_session('baby_id'),
                           entrance=get_session('entrance'),
                           analysis=analysis,
                           breastfeeding=breastfeeding,
                           formula_feeding=formula_feeding,
                           grow_time=grow_time)
Exemple #3
0
def to_record(baby_id):
    entrance = str(request.args.get('entrance_type', 'doctor'))
    record, record_count, baby = get_visit_record(baby_id)
    login_id = 0
    if entrance == 'baby':
        set_session_user('entrance', entrance,'user_id', baby_id)
        login_id = get_session('user_id')
    else:
        set_session_user('entrance', entrance,'baby_id', baby_id)
        login_id = get_session('baby_id')
    return render_template('baby/visit_record.html',
                           record=record,
                           record_count=record_count,
                           baby=baby,
                           user_id=login_id,
                           entrance=entrance)
Exemple #4
0
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
Exemple #5
0
def to_grow_rate(baby_id):
    # record, record_count, baby = get_visit_record(baby_id)
    grow_time, grow_rate, baby = get_record_time_and_rate(baby_id)
    return render_template('baby/grow_rate.html',
                           user_id=get_session('baby_id'),
                           baby=baby,
                           grow_time=grow_time,
                           grow_rate=grow_rate)
Exemple #6
0
def to_nine_grow_line(baby_id):
    record, record_count, baby = get_visit_record(baby_id)
    show_data_way = check_baby_is_week_or_month(baby)
    types = request.args.get('type', 'weight')
    way = request.args.get('way', 'week')
    select_type = get_session('select_type')
    if baby:
        baby.select_type = select_type
    tracking = get_tracking(baby_id, types, show_data_way, None)
    grow_p3, grow_p15, grow_p75, grow_p95, grow_negative3, grow_negative2, grow_negative1 = get_nine_standard(baby_id, types)
    if types == 'weight':
            return render_template('baby/grow_line_nine.html',
                                   tracking=tracking,
                                   types=types,
                                   user_id=get_session('baby_id'),
                                   entrance=get_session('entrance'),
                                   baby=baby,
                                   grow_p3=grow_p3,
                                   grow_p15=grow_p15,
                                   grow_p75=grow_p75,
                                   grow_p95=grow_p95,
                                   grow_negative3=grow_negative3,
                                   grow_negative2=grow_negative2,
                                   grow_negative1=grow_negative1)
    if types == 'height':
        return render_template('baby/grow_line_nine_height.html',
                               tracking=tracking,
                               types=types,
                               user_id=get_session('baby_id'),
                               entrance=get_session('entrance'),
                               baby=baby,
                               grow_p3=grow_p3,
                               grow_p15=grow_p15,
                               grow_p75=grow_p75,
                               grow_p95=grow_p95,
                               grow_negative3=grow_negative3,
                               grow_negative2=grow_negative2,
                               grow_negative1=grow_negative1)
    if types == 'head':
        return render_template('baby/grow_line_nine_head.html',
                               tracking=tracking,
                               types=types,
                               user_id=get_session('baby_id'),
                               entrance=get_session('entrance'),
                               baby=baby,
                               grow_p3=grow_p3,
                               grow_p15=grow_p15,
                               grow_p75=grow_p75,
                               grow_p95=grow_p95,
                               grow_negative3=grow_negative3,
                               grow_negative2=grow_negative2,
                               grow_negative1=grow_negative1)
Exemple #7
0
def to_grow_line(baby_id):
    record, record_count, baby = get_visit_record(baby_id)
    show_data_way = check_baby_is_week_or_month(baby)
    types = request.args.get('type', 'weight')
    select_type = request.args.get('select_type', 'doctor')
    set_session_user('select_type', select_type, '','')
    if baby:
        baby.select_type = select_type
    way = request.args.get('way', 'week')
    tracking = get_tracking(baby_id, types, show_data_way, None)
    grow_p3, grow_p15, grow_p75, grow_p95 = get_who_standard(baby_id, types)
    if show_data_way == 'week' and way == 'week':
        tracking = get_tracking_week(baby_id, types, show_data_way, None)
        if types == 'weight':
            if baby.is_compare == 40:
                tracking = get_tracking_week(baby_id, types, show_data_way, 'fen_tong')
                grow_p3, grow_p15, grow_p75, grow_p95, grow_negative3 = get_fen_tong_standard(baby_id, types)
                return render_template('baby/grow_line_fentong_weight.html',
                               tracking=tracking,
                               types=types,
                               user_id=get_session('baby_id'),
                               entrance=get_session('entrance'),
                               baby=baby,
                               grow_p3=grow_p3,
                               grow_p15=grow_p15,
                               grow_p75=grow_p75,
                               grow_p95=grow_p95,
                               grow_negative3=grow_negative3)
            return render_template('baby/grow_line.html',
                                   tracking=tracking,
                                   types=types,
                                   user_id=get_session('baby_id'),
                                   entrance=get_session('entrance'),
                                   baby=baby,
                                   grow_p3=grow_p3,
                                   grow_p15=grow_p15,
                                   grow_p75=grow_p75,
                                   grow_p95=grow_p95)
        if types == 'height':
            return render_template('baby/grow_line_height_week.html',
                                   tracking=tracking,
                                   types=types,
                                   user_id=get_session('baby_id'),
                                   entrance=get_session('entrance'),
                                   baby=baby,
                                   grow_p3=grow_p3,
                                   grow_p15=grow_p15,
                                   grow_p75=grow_p75,
                                   grow_p95=grow_p95)
        if types == 'head':
            return render_template('baby/grow_line_head_week.html',
                                   tracking=tracking,
                                   types=types,
                                   user_id=get_session('baby_id'),
                                   entrance=get_session('entrance'),
                                   baby=baby,
                                   grow_p3=grow_p3,
                                   grow_p15=grow_p15,
                                   grow_p75=grow_p75,
                                   grow_p95=grow_p95)
    else:
        grow_p3, grow_p15, grow_p75, grow_p95 = get_who_standard_month(baby_id, types)
        if types == 'weight':
            if baby.is_compare == 40:
                tracking = get_tracking(baby_id, types, show_data_way, 'fen_tong')
                grow_p3, grow_p15, grow_p75, grow_p95, grow_negative3 = get_fen_tong_standard(baby_id, types)
                return render_template('baby/grow_line_fentong_weight.html',
                               tracking=tracking,
                               types=types,
                               user_id=get_session('baby_id'),
                               entrance=get_session('entrance'),
                               baby=baby,
                               grow_p3=grow_p3,
                               grow_p15=grow_p15,
                               grow_p75=grow_p75,
                               grow_p95=grow_p95,
                               grow_negative3=grow_negative3)
            return render_template('baby/grow_line_month.html',
                                   tracking=tracking,
                                   types=types,
                                   user_id=get_session('baby_id'),
                                   entrance=get_session('entrance'),
                                   baby=baby,
                                   grow_p3=grow_p3,
                                   grow_p15=grow_p15,
                                   grow_p75=grow_p75,
                                   grow_p95=grow_p95)
        if types == 'height':
            return render_template('baby/grow_line_height_month.html',
                                   tracking=tracking,
                                   types=types,
                                   user_id=get_session('baby_id'),
                                   entrance=get_session('entrance'),
                                   baby=baby,
                                   grow_p3=grow_p3,
                                   grow_p15=grow_p15,
                                   grow_p75=grow_p75,
                                   grow_p95=grow_p95)
        if types == 'head':
            return render_template('baby/grow_line_head_month.html',
                                   tracking=tracking,
                                   types=types,
                                   user_id=get_session('baby_id'),
                                   entrance=get_session('entrance'),
                                   baby=baby,
                                   grow_p3=grow_p3,
                                   grow_p15=grow_p15,
                                   grow_p75=grow_p75,
                                   grow_p95=grow_p95)
Exemple #8
0
def to_baby_detail(baby_id):
    baby = get_baby_by_id(baby_id)
    return render_template('baby/detail_info.html',
                           baby=baby,
                           user_id=get_session('baby_id'),
                           entrance=get_session('entrance'))