예제 #1
0
def profile():
    ''' Get or update personal profile '''
    g.current_page = 'profile'
    g.breadcrumb = None
    if request.method == 'POST':
        models.modify_user(g._user['id'], request.form['nickname'])
        flash('更新昵称成功', 'success')
    threads = models.get_user_thread(g._user['id'])
    return render_template('profile.html', threads=threads)
예제 #2
0
def updateUser():
    _id = request.form.get('id', '')
    _user = models.get_user_by_id(_id)
    if _user is None:
        return render_template('update.html', result='用户信息不存在')
    else:
        telephone = request.form.get('telephone', '')
        age = request.form.get('age', '')

        # 检查用户提交的数据
        ok, result = models.validate_user_modify(telephone, age)

        # 如果检查通过则添加到DB
        if ok:
            if models.modify_user(_user['id'], telephone, age):
                ok = True
                result = '更新成功'
            else:
                ok = False
                result = '更新失败'
        if ok:
            #return redirect('/users/')
            return json.dumps({'ok': True})
        else:
            return json.dumps({'ok': False, 'result': result})
예제 #3
0
def updateUser():
    _id = request.form.get('id', '')
    _user = models.get_user_by_id(_id)
    if _user is None:
        return render_template('update.html', result='用户信息不存在')
    else:
        telephone = request.form.get('telephone', '')
        age = request.form.get('age', '')

        # 检查用户提交的数据
        ok, result = models.validate_user_modify(telephone, age)
        
        # 如果检查通过则添加到DB
        if ok:
            if models.modify_user(_user['id'], telephone, age):
                ok = True
                result = '更新成功'
            else:
                ok = False
                result = '更新失败'
        if ok:
            #return redirect('/users/')
            return json.dumps({'ok' : True})
        else:
            return json.dumps({'ok' : False, 'result' : result})
예제 #4
0
def updateUser():
    _id = request.form.get("id", "")
    _user = models.get_user_by_id(_id)
    if _user is None:
        return render_template("update.html", result="用户信息不存在")
    else:
        telephone = request.form.get("telephone", "")
        age = request.form.get("age", "")

        # 检查用户提交的数据
        ok, result = models.validate_user_modify(telephone, age)

        # 如果检查通过则添加到DB
        if ok:
            if models.modify_user(_user["id"], telephone, age):
                ok = True
                result = "更新成功"
            else:
                ok = False
                result = "更新失败"
        if ok:
            return redirect("/users/")
        else:
            return render_template(
                "update.html", result=result, id=_user["id"], username=_user["username"], telephone=telephone, age=age
            )
예제 #5
0
def updateuser():
    password = request.form.get('password', '')
    email = request.form.get('email', '')
    id = request.form.get('id', '')
    if models.modify_user(password,email,id):
        ok = True
        result = "ok"
    else:
        ok = False
        result = 'error'
    if ok:
        return json.dumps({'ok' : True})
    else:
        return json.dumps({'ok': False,'result' :result})
예제 #6
0
def updateuser():
    password = request.form.get('password', '')
    email = request.form.get('email', '')
    id = request.form.get('id', '')
    if models.modify_user(password, email, id):
        ok = True
        result = "ok"
    else:
        ok = False
        result = 'error'
    if ok:
        return json.dumps({'ok': True})
    else:
        return json.dumps({'ok': False, 'result': result})
예제 #7
0
def user_modify():
    new_user = {}
    username = request.form.get('username')
    new_user['id'] = int(request.form.get('id', '').strip())
    new_user['username'] = request.form.get('username', '').strip()
    new_user['password'] = request.form.get('password', '').strip()
    new_user['group'] = request.form.get('group', '').strip()
    new_user['tel'] = request.form.get('tel', '').strip()
    new_user['status'] = request.form.get('status', '').strip()

    result = models.same_user(request.form.get('username'),
                              int(request.form.get('id')))
    if result:
        return render_template('/user_modify.html/',
                               error='Same name erro.',
                               id=int(request.form.get('id')),
                               username=username,
                               password=request.form.get('password'),
                               group=request.form.get('group'),
                               tel=request.form.get('tel'),
                               status=request.form.get('status'))
    else:
        models.modify_user(new_user)
        return redirect('/users/')