Esempio n. 1
0
def insert_formula(court_id, brand_id, type, energy, protein, carbon_compound, axunge):
    """

    """
    type_of_milk = TypeOfMilk(court_id=court_id, bran_id=brand_id, type=type, energy=energy, protein=protein,
                            carbon_compound=carbon_compound, axunge=axunge)
    db.add(type_of_milk)
    try:
        db.commit()
    except:
        return False
    return True
Esempio n. 2
0
def register_doctor(login_name, login_pass, argument_real_name, argument_province, argument_belong_hospital,
                    argument_belong_department, argument_position, argument_email, argument_tel):
    """
       注册医师
    """
    doctor_result = Doctor.query.filter(or_(Doctor.doctor_name == login_name, Doctor.email == argument_email, Doctor.tel == argument_tel)).first()
    if doctor_result:
        return 0
    else:
        doctor = Doctor(doctor_name=login_name, doctor_pass=login_pass, real_name=argument_real_name, province=argument_province,
                        belong_hospital=argument_belong_hospital, belong_department=argument_belong_department, position=argument_position,
                        email=argument_email, tel=argument_tel)
        try:
            db.add(doctor)
            db.commit()
        except:
            return 0
        return doctor.id
Esempio n. 3
0
def insert_or_cancel_collects(doctor_id, type_id, collect_type):
    '''添加收藏'''
    result = check_is_collect(doctor_id, type_id, collect_type)
    if result:
        try:
            db.delete(result)
            db.commit()
        except:
            return False
        return True
    else:
        collect = Collect(doctor_id=doctor_id, type_id=type_id, type=collect_type)
        try:
            db.add(collect)
            db.commit()
        except:
            return False
        return True
Esempio n. 4
0
def update_doctor(doctor_id, real_name, province_id, belong_hospital_id, belong_department, position, email, tel, upload_image, success):
    """
    修改医生个人资料
    """
    doctor = doctor_info(doctor_id)
    if doctor:
        if real_name:
            doctor.real_name = real_name
        if province_id:
            doctor.province_id = province_id
        if belong_hospital_id:
            doctor.belong_hospital_id = belong_hospital_id
        if belong_department:
            doctor.belong_department = belong_department
        if position:
            doctor.position = position
        if email:
            doctor.email = email
        if tel:
            doctor.tel = tel
        if upload_image:
            if not allowed_file_extension(upload_image.stream.filename, HEAD_PICTURE_ALLOWED_EXTENSION):
                return False
            old_picture = str(doctor.rel_path) + '/' + str(doctor.picture_name)
            base_path = HEAD_PICTURE_BASE_PATH
            doctor.rel_path = HEAD_PICTURE_UPLOAD_FOLDER
            doctor.picture_name = time_file_name(secure_filename(upload_image.stream.filename), sign=doctor_id)
            upload_image.save(os.path.join(base_path + doctor.rel_path+'/', doctor.picture_name))
            try:
                os.remove(old_picture)
            except:
                pass
        doctor_pickler(doctor, success)
        db.commit()
        return True
    else:
        return False