예제 #1
0
def save_register():
    u = connection.User.one({'active': 0, 'email': _g("email")})
    if u:
        flash("The user has been already exist !", MESSAGE_ERROR)
        return redirect(url_for("register"))
    if _g("password") != _g("repassword"):
        flash("The password and confirmed password are not the same !",
              MESSAGE_ERROR)
        return redirect(url_for("register"))
    if not _g("first_name") or not _g("last_name"):
        flash("The first name or the last name is not supplied !",
              MESSAGE_ERROR)
        return redirect(url_for("register"))

    nu = connection.User()
    nu.id = nu.getID()
    nu.email = _g("email")
    nu.password = _g("password")
    nu.first_name = _g("first_name")
    nu.last_name = _g("last_name")
    nu.phone = _g("phone")
    nu.birthday = _g("birthday")

    r = connection.Role.one({"name": "NORMALUSER"})
    nu.roles = [r.id]
    r.users = r.users + [nu.id]
    nu.save()
    r.save()

    flash("Register successfully", MESSAGE_INFO)
    return redirect(url_for("login"))
예제 #2
0
def test():

    u = connection.User()
    u.email = request.values.get("email", "")
    u.password = request.values.get("password", "")
    u.save()
    return u.to_json()
예제 #3
0
def init():
    db = getattr(connection, MONGODB_DB)
    objects = [Sequence, UploadFile, SystemLog]
    objects.extend([getattr(auth, name) for name in auth.__all__])
    objects.extend([getattr(logic, name) for name in logic.__all__])

    print "*" * 20
    print "drop all collection"
    print "_" * 20
    #clear the DB
    for o in objects:
        print str(o)
        db.drop_collection(o.__collection__)

    print "*" * 20
    print "Init the sequence"
    print "_" * 20
    #init the seq
    for o in objects:
        seq = connection.Sequence()
        seq.name = unicode(o.__collection__)
        seq.save()

    print "*" * 20
    print "Adding the default data"
    print "_" * 20
    #init the permission
    permissions = [
        "ORDER_ADD",
        "ORDER_VIEW",
        "ORDER_CANCEL",
        "ORDER_UPDATE",
        "ORDER_VIEW_ALL",
        "CLINIC_ADD",
        "CLINIC_VIEW",
        "CLINIC_VIEW_ALL",
        "CLINIC_UPDATE",
        "CLINIC_DELETE",
        "DOCTOR_ADD",
        "DOCTOR_UPDATE",
        "DOCTOR_DELETE",
        "NURSE_ADD",
        "NURSE_UPDATE",
        "NURSER_DELETE",
    ]
    permissions_mapping = {}
    for p in permissions:
        obj = connection.Permission()
        obj.name = unicode(p)
        obj.id = obj.getID()
        #        obj.save()
        permissions_mapping[p] = obj

    #add the HK holiday
    for d in [
            "0101", "0203", "0204", "0205", "0405", "0423", "0425", "0502",
            "0510", "0606", "0701", "0913", "1001", "1005", "1226", "1227"
    ]:
        day = connection.Holiday()
        day.id = day.getID()
        day.year = 2011
        day.month = int(d[:2])
        day.day = int(d[-2:])
        day.save()

    users = [
        ("*****@*****.**", "Admin", "Lam"),
        ("*****@*****.**", "Clinic Manager 1", "Lam"),
        ("*****@*****.**", "Clinic Manager 2", "Lam"),
        ("*****@*****.**", "User 1", "Lam"),
        ("*****@*****.**", "User 2", "Lam"),
        ("*****@*****.**", "Temp 1", "Lam"),
        ("*****@*****.**", "Temp 2", "Lam"),
    ]
    users_mapping = {}
    for (email, first_name, last_name) in users:
        u = connection.User()
        u.email = unicode(email)
        u.password = u"aa"
        u.first_name = unicode(first_name)
        u.last_name = unicode(last_name)
        u.id = u.getID()
        #        u.save()
        users_mapping[email] = u

    roles = [("ADMINISTRATOR", "Administrator"),
             ("CLINIC_MANAGER", "Clinic Manager"), ("DOCTOR", "Doctor"),
             ("NURSE", "Nurse"), ("NORMALUSER", "Normal User"),
             ("TEMPUSER", "Temp User")]
    roles_mapping = {}
    for (name, display_name) in roles:
        r = connection.Role()
        r.name = unicode(name)
        r.display = unicode(display_name)
        r.id = r.getID()
        #        r.save()
        roles_mapping[name] = r

    users_mapping["*****@*****.**"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
    ]
    users_mapping["*****@*****.**"].roles = [
        roles_mapping["CLINIC_MANAGER"].id,
    ]
    users_mapping["*****@*****.**"].roles = [
        roles_mapping["CLINIC_MANAGER"].id,
    ]
    users_mapping["*****@*****.**"].roles = [
        roles_mapping["NORMALUSER"].id,
    ]
    users_mapping["*****@*****.**"].roles = [
        roles_mapping["NORMALUSER"].id,
    ]
    users_mapping["*****@*****.**"].roles = [
        roles_mapping["TEMPUSER"].id,
    ]
    users_mapping["*****@*****.**"].roles = [
        roles_mapping["TEMPUSER"].id,
    ]

    roles_mapping["ADMINISTRATOR"].permissions = [
        v.id for k, v in permissions_mapping.items()
    ]
    roles_mapping["ADMINISTRATOR"].users = [
        users_mapping["*****@*****.**"].id,
    ]
    roles_mapping["CLINIC_MANAGER"].permissions = [
        permissions_mapping["CLINIC_VIEW"].id,
        permissions_mapping["CLINIC_UPDATE"].id,
        permissions_mapping["DOCTOR_ADD"].id,
        permissions_mapping["DOCTOR_UPDATE"].id,
        permissions_mapping["DOCTOR_DELETE"].id,
        permissions_mapping["NURSE_ADD"].id,
        permissions_mapping["NURSE_UPDATE"].id,
        permissions_mapping["NURSER_DELETE"].id,
        permissions_mapping["ORDER_VIEW"].id,
        permissions_mapping["ORDER_CANCEL"].id,
        permissions_mapping["ORDER_UPDATE"].id,
    ]
    roles_mapping["CLINIC_MANAGER"].users = [
        users_mapping["*****@*****.**"].id, users_mapping["*****@*****.**"].id
    ]
    roles_mapping["DOCTOR"].permissions = [
        permissions_mapping["ORDER_VIEW"].id,
        permissions_mapping["ORDER_CANCEL"].id,
        permissions_mapping["ORDER_UPDATE"].id,
    ]
    roles_mapping["DOCTOR"].users = []
    roles_mapping["NURSE"].permissions = [
        permissions_mapping["ORDER_VIEW"].id,
        permissions_mapping["ORDER_CANCEL"].id,
        permissions_mapping["ORDER_UPDATE"].id,
    ]
    roles_mapping["NURSE"].users = []
    roles_mapping["NORMALUSER"].permissions = [
        permissions_mapping["ORDER_ADD"].id,
        permissions_mapping["ORDER_VIEW"].id,
        permissions_mapping["ORDER_CANCEL"].id,
    ]
    roles_mapping["NORMALUSER"].users = [
        users_mapping["*****@*****.**"].id, users_mapping["*****@*****.**"].id
    ]
    roles_mapping["TEMPUSER"].permissions = []
    roles_mapping["TEMPUSER"].users = [
        users_mapping["*****@*****.**"].id, users_mapping["*****@*****.**"].id
    ]

    permissions_mapping["ORDER_ADD"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
        roles_mapping["NORMALUSER"].id,
    ]
    permissions_mapping["ORDER_VIEW"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
        roles_mapping["CLINIC_MANAGER"].id,
        roles_mapping["DOCTOR"].id,
        roles_mapping["NURSE"].id,
    ]
    permissions_mapping["ORDER_CANCEL"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
        roles_mapping["NORMALUSER"].id,
        roles_mapping["DOCTOR"].id,
        roles_mapping["NURSE"].id,
    ]
    permissions_mapping["ORDER_UPDATE"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
        roles_mapping["CLINIC_MANAGER"].id,
        roles_mapping["DOCTOR"].id,
        roles_mapping["NURSE"].id,
    ]
    permissions_mapping["ORDER_VIEW_ALL"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
    ]
    permissions_mapping["CLINIC_ADD"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
    ]
    permissions_mapping["CLINIC_VIEW"].roles = [
        roles_mapping["ADMINISTRATOR"].id, roles_mapping["CLINIC_MANAGER"].id
    ]
    permissions_mapping["CLINIC_VIEW_ALL"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
    ]
    permissions_mapping["CLINIC_UPDATE"].roles = [
        roles_mapping["ADMINISTRATOR"].id, roles_mapping["CLINIC_MANAGER"].id
    ]
    permissions_mapping["CLINIC_DELETE"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
    ]
    permissions_mapping["DOCTOR_ADD"].roles = [
        roles_mapping["ADMINISTRATOR"].id, roles_mapping["CLINIC_MANAGER"].id
    ]
    permissions_mapping["DOCTOR_UPDATE"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
        roles_mapping["CLINIC_MANAGER"].id,
    ]
    permissions_mapping["DOCTOR_DELETE"].roles = [
        roles_mapping["ADMINISTRATOR"].id, roles_mapping["CLINIC_MANAGER"].id
    ]
    permissions_mapping["NURSE_ADD"].roles = [
        roles_mapping["ADMINISTRATOR"].id, roles_mapping["CLINIC_MANAGER"].id
    ]
    permissions_mapping["NURSE_UPDATE"].roles = [
        roles_mapping["ADMINISTRATOR"].id,
        roles_mapping["CLINIC_MANAGER"].id,
    ]
    permissions_mapping["NURSER_DELETE"].roles = [
        roles_mapping["ADMINISTRATOR"].id, roles_mapping["CLINIC_MANAGER"].id
    ]

    from clinic_list import clinics
    clinics_mapping = {}

    for (code, name, address, tel) in clinics:
        c = connection.Clinic()
        c.id = c.getID()
        c.code = unicode(code)
        c.name = unicode(name)
        c.address = unicode(address)
        c.tel = unicode(tel)

        u = connection.User()
        u.id = u.getID()
        u.email = unicode("*****@*****.**" % code)
        u.password = u"aa"
        u.first_name = unicode(code)
        u.last_name = unicode("Nurse")

        n = connection.NurseProfile()
        n.id = n.getID()
        n.uid = u.id
        n.desc = u"I'm nurse."
        n.clinic = [c.id]

        c.nurses = [n.id]
        c.doctors = []
        roles_mapping["NURSE"].users.append(n.id)

        u.save()
        c.save()
        n.save()

        clinics_mapping[code] = c

    from doctors_list import doctors
    doctors_count = {}
    default_worktime = {
        "MONDAY": [],
        "TUESDAY": [],
        "WEDNESDAY": [],
        "THURSDAY": [],
        "FRIDAY": [],
        "SATURDAY": [],
        "SUNDAY": [],
        "HOLIDAY": [],
        "SPECIAL": [],
    }
    for (code, first_name, last_name, worktime) in doctors:
        u = connection.User()
        u.id = u.getID()

        if code in doctors_count: doctors_count[code] += 1
        else: doctors_count[code] = 1

        u.email = unicode("*****@*****.**" %
                          (code, doctors_count[code]))
        u.password = u"aa"
        u.first_name = unicode(first_name)
        u.last_name = unicode(last_name)
        u.roles = [
            roles_mapping["DOCTOR"].id,
        ]
        roles_mapping["DOCTOR"].users.append(u.id)

        tempWorkTime = default_worktime.copy()
        tempWorkTime.update(worktime)
        for k, v in tempWorkTime.items():
            tempWorkTime[k] = map(lambda o: {"times": o, "seats": 4}, v)
        c = clinics_mapping[code]
        d = connection.DoctorProfile()
        d.id = d.getID()
        d.uid = u.id
        d.clinic = [c.id]
        d.worktime_setting = tempWorkTime
        c.doctors.append(d.id)
        c.save()
        u.save()
        d.save()

    for m in [users_mapping, roles_mapping, permissions_mapping]:
        for k, v in m.items():
            v.save()

    print "*" * 20
    print "finish"
    print "_" * 20
예제 #4
0
def init():
    db = getattr(connection, MONGODB_DB)
    objects = [Sequence]
    objects.extend([getattr(auth, name) for name in auth.__all__])
    objects.extend([getattr(logic, name) for name in logic.__all__])

    print "*" * 20
    print "drop all collection"
    print "_" * 20
    #clear the DB
    for o in objects:
        print str(o)
        db.drop_collection(o.__collection__)

    print "*" * 20
    print "Init the sequence"
    print "_" * 20
    #init the seq
    for o in objects:
        seq = connection.Sequence()
        seq.name = unicode(o.__collection__)
        seq.save()


    print "*" * 20
    print "Adding the default data"
    print "_" * 20
    #init the permission
    pcreate_clinic = connection.Permission()
    pcreate_clinic.name = u'CREATE_CLINIC'
    pcreate_clinic.save()

    padd_user = connection.Permission()
    padd_user.name = u'ADD_USER'
    padd_user.save()

    pdelete_user = connection.Permission()
    pdelete_user.name = u'DELETE_NAME'
    pdelete_user.save()

    pdelete_role = connection.Permission()
    pdelete_role.name = u'DELETE_ROLE'
    pdelete_role.save()

    pview_all_clinic = connection.Permission()
    pview_all_clinic.name = u'VIEW_ALL_CLINIC'
    pview_all_clinic.save()

    pview_order = connection.Permission()
    pview_order.name = u'VIEW_ORDER'
    pview_order.save()





    #add the init value into db
    admin = connection.User()
    admin.email = u'*****@*****.**'
    admin.password = u'aa'
    admin.first_name = u'Admin'
    admin.last_name = u'Test'
    admin.id = admin.getID()
    admin.save()

    temp1 = connection.User()
    temp1.email = u'*****@*****.**'
    temp1.password = u'aa'
    temp1.id = temp1.getID()
    temp1.first_name = u"Temp1"
    temp1.last_name = u"KK"
    temp1.save()

    temp2 = connection.User()
    temp2.email = u'*****@*****.**'
    temp2.password = u'aa'
    temp2.id = temp2.getID()
    temp2.first_name = u"Temp2"
    temp2.last_name = u"KK"
    temp2.save()

    temp3 = connection.User()
    temp3.email = u'*****@*****.**'
    temp3.password = u'aa'
    temp3.id = temp3.getID()
    temp3.first_name = u"Temp3"
    temp3.last_name = u"KK"
    temp3.save()

    temp4 = connection.User()
    temp4.email = u'*****@*****.**'
    temp4.password = u'aa'
    temp4.id = temp4.getID()
    temp4.first_name = u"Temp4"
    temp4.last_name = u"KK"
    temp4.save()

    radmin = connection.Role()
    radmin.name = u'ADMINISTRATOR'
    radmin.display = u'Administrator'
    radmin.users = [admin.id]
    radmin.id = radmin.getID()
    radmin.save()

    rdoctor = connection.Role()
    rdoctor.name = u'DOCTOR'
    rdoctor.displayname = u'Doctor'
    rdoctor.id = rdoctor.getID()
    rdoctor.save()

    rnurse = connection.Role()
    rnurse.name = u'NURSE'
    rnurse.displayname = u'Nurse'
    rnurse.id = rnurse.getID()
    rnurse.save()

    ruser = connection.Role()
    ruser.name = u'NORMALUSER'
    ruser.displayname = u'Normal User'
    ruser.id = ruser.getID()
    ruser.save()

    rtemp = connection.Role()
    rtemp.name = u'TEMPUSER'
    rtemp.displayname = u'Temp User'
    rtemp.id = rtemp.getID()
    rtemp.users = [temp1.id, temp2.id]
    rtemp.save()


    c1 = connection.Clinic()
    c1.id = c1.getID()
    c1.address = u"C1 Address"
    c1.name = u'Clinic 1'
    c1.location = (22.396428, 114.1094970)
    c1.save()

    c2 = connection.Clinic()
    c2.id = c2.getID()
    c2.address = u"C2 Address"
    c2.name = u'Clinic 2'
    c2.location = (22.396428, 114.0094970)
    c2.save()

    c3 = connection.Clinic()
    c3.id = c3.getID()
    c3.name = u'Clinic 3'
    c3.address = u"C3 Address"
    c3.location = (22.296428, 114.0094970)
    c3.save()

    c4 = connection.Clinic()
    c4.id = c4.getID()
    c4.address = u"C4 Address"
    c4.name = u'Clinic 4'
    c4.location = (22.286428, 114.1094970)
    c4.save()

    c5 = connection.Clinic()
    c5.id = c5.getID()
    c5.name = u'Clinic 5'
    c1.address = u"C5 Address"
    c5.location = (22.284428, 114.1094970)
    c5.save()


    d1 = connection.DoctorProfile()
    d1.id = d1.getID()
    d1.uid = temp1.id
    d1.desc = u"I'm temp 1 doctor."
    d1.clinic = [c1.id]
    d1.save()

    d2 = connection.DoctorProfile()
    d2.id = d2.getID()
    d2.uid = temp2.id
    d2.desc = u"I'm temp 2 doctor."
    d2.clinic = [c1.id]
    d2.save()

    d3 = connection.DoctorProfile()
    d3.id = d3.getID()
    d3.uid = temp3.id
    d3.desc = u"I'm temp 3 doctor."
    d3.clinic = [c1.id]
    d3.save()

    d4 = connection.DoctorProfile()
    d4.id = d4.getID()
    d4.uid = temp4.id
    d4.desc = u"I'm temp 4 doctor."
    d4.clinic = [c2.id]
    d3.save()

    c1.doctors = [d1.id, d2.id, d3.id]
    c2.doctors = [d4.id]
    c1.save()
    c2.save()

    print "*" * 20
    print "finish"
    print "_" * 20
예제 #5
0
def m_nurse_save():
    required_fields = ["email", "first_name", "last_name"]
    for f in required_fields:
        if not _g(f):
            flash("The required field is not supplied !", MESSAGE_ERROR)
            return redirect(url_for("m_nurse_list"))

    action_type = _g("action_type")
    _gl = request.form.getlist
    if action_type == "NEW":
        if not _g("password") or not _g("repassword"):
            flash("The required field is not supplied !", MESSAGE_ERROR)
            return redirect(url_for("m_nurse_list"))

        if _g("password") != _g("repassword"):
            flash("The password and the confirmed password are not the same !",
                  MESSAGE_ERROR)
            return redirect(url_for("m_nurse_list"))
        u = connection.User()
        u.id = u.getID()
        u.email = _g("email")
        u.password = _g("password")
        u.first_name = _g("first_name")
        u.last_name = _g("last_name")
        u.phone = _g("phone")
        u.birthday = _g("birthday")
        r = connection.Role.one({'active': 0, 'name': 'NURSE'})
        r.users.append(u.id)
        u.roles = [r.id]
        try:
            f = upload("image_url")
            u.image_url = f.id
        except:
            app.logger.error(traceback.format_exc())
        r.save()
        u.save()

        n = connection.NurseProfile()
        n.id = n.getID()
        n.uid = u.id
        n.desc = _g("desc")

        n.clinic = map(int, _gl("clinic"))
        for c in n.clinic:
            connection.Clinic.one({"id": c}).nurses.append(n.id)
        n.save()
        flash("Save the new nurse successfully!", MESSAGE_INFO)
        return redirect(url_for("m_nurse_list"))

    elif action_type == 'UPDATE':
        id = _g("id")
        if not id:
            flash("No nurse id supplied!", MESSAGE_ERROR)
            return redirect(url_for("m_doctor_list"))
        n = connection.NurseProfile.one({'id': int(id)})
        n.desc = _g("desc")
        #map the relation
        n.clinic = map(int, _gl("clinic"))
        for c in n.clinic:
            connection.Clinic.one({"id": c}).nurses.append(n.id)
        n.save()
        u = connection.User.one({'id': n.uid})
        u.email = _g("email")
        u.first_name = _g("first_name")
        u.last_name = _g("last_name")
        u.phone = _g("phone")
        u.birthday = _g("birthday")
        try:
            f = upload("image_url")
            u.image_url = f.id
        except:
            app.logger.error(traceback.format_exc())
        u.save()
        flash("Save the update successfully !", MESSAGE_INFO)
        return redirect(url_for("m_nurse_list"))
    else:
        flash("No such action type !", MESSAGE_ERROR)
        return redirect(url_for("m_nurse_list"))
예제 #6
0
def m_doctor_save():
    required_fields = ["email", "first_name", "last_name"]
    for f in required_fields:
        if not _g(f):
            flash("The required field is not supplied !", MESSAGE_ERROR)
            return redirect(url_for("m_doctor_list"))

    action_type = _g("action_type")
    _gl = request.form.getlist  #could not move it outside the function , don't know why
    if action_type == "NEW":
        if not _g("password") or not _g("repassword"):
            flash("The required field is not supplied !", MESSAGE_ERROR)
            return redirect(url_for("m_doctor_list"))

        if _g("password") != _g("repassword"):
            flash("The password and the confirmed password are not the same !",
                  MESSAGE_ERROR)
            return redirect(url_for("m_doctor_list"))

        u = connection.User()
        u.id = u.getID()
        u.email = _g("email")
        u.password = _g("password")
        u.first_name = _g("first_name")
        u.last_name = _g("last_name")
        u.phone = _g("phone")
        u.birthday = _g("birthday")
        r = connection.Role.one({'active': 0, 'name': 'DOCTOR'})
        r.users.append(u.id)
        u.roles = [r.id]
        try:
            f = upload("image_url")
            u.image_url = f.id
        except:
            app.logger.error(traceback.format_exc())
        r.save()
        u.save()

        d = connection.DoctorProfile()
        d.id = d.getID()
        d.uid = u.id
        d.desc = _g("desc")
        #        d.qty = int(_g("qty"))  if _g("qty") else 10
        #map the relation
        d.category = map(int, _gl("category"))
        for c in d.category:
            connection.Category.one({'id': c}).doctors.append(d.id)
        d.clinic = map(int, _gl("clinic"))
        for c in d.clinic:
            connection.Clinic.one({"id": c}).doctors.append(d.id)

        #        d.avaiable_day = map(int, _gl("avaiable_day"))
        for day in [
                "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY",
                "SATURDAY", "SUNDAY", "HOLIDAY"
        ]:
            app.logger.info(request.form.getlist("time_" + day))
            ts = [
                map(lambda v: ("0" + v)[-5:], t.split("|"))
                for t in request.form.getlist("time_" + day)
            ]
            ts.sort(cmp=lambda a, b: cmp(a[0], b[0]))
            app.logger.info(ts)
            d.worktime_setting[day] = ts

        d.save()
        flash("Save the new doctor successfully!", MESSAGE_INFO)
        return redirect(url_for("m_doctor_list"))

    elif action_type == 'UPDATE':
        id = _g("id")
        if not id:
            flash("No doctor id supplied!", MESSAGE_ERROR)
            return redirect(url_for("m_doctor_list"))
        d = connection.DoctorProfile.one({'id': int(id)})
        d.desc = _g("desc")
        #map the relation
        d.category = map(int, _gl("category"))
        for c in d.category:
            connection.Category.one({'id': c}).doctors.append(d.id)
        d.clinic = map(int, _gl("clinic"))
        for c in d.clinic:
            connection.Clinic.one({"id": c}).doctors.append(d.id)

        for day in [
                "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY",
                "SATURDAY", "SUNDAY", "HOLIDAY"
        ]:
            app.logger.info(request.form.getlist("time_" + day))
            ts = [
                map(lambda v: ("0" + v)[-5:], t.split("|"))
                for t in request.form.getlist("time_" + day)
            ]
            ts.sort(cmp=lambda a, b: cmp(a[0], b[0]))
            app.logger.info(ts)
            d.worktime_setting[day] = ts


#        d.avaiable_day = map(int, _gl("avaiable_day"))
        d.save()
        u = connection.User.one({'id': d.uid})
        u.email = _g("email")
        u.first_name = _g("first_name")
        u.last_name = _g("last_name")
        u.phone = _g("phone")
        u.birthday = _g("birthday")
        try:
            f = upload("image_url")
            u.image_url = f.id
        except:
            app.logger.error(traceback.format_exc())
        u.save()

        flash("Save the update successfully !", MESSAGE_INFO)
        return redirect(url_for("m_doctor_list"))
    else:
        flash("No such action type !", MESSAGE_ERROR)
        return redirect(url_for("m_doctor_list"))