Ejemplo n.º 1
0
def updateone():
    if request.method=='GET':
        id = request.args.get('id')
	return render_template('updateone.html',user = db.update_list(id))
    else:
	data = dict(request.form)
        conditions = [ "%s='%s'" %  (k,v[0]) for k,v in data.items()]
        db.update(conditions,data['id'][0])

	return render_template('userone.html',user = db.update_list(data['id'][0]))
Ejemplo n.º 2
0
def updateone():
    if request.method == 'GET':
        id = request.args.get('id')
        return render_template('updateone.html', user=db.update_list(id))
    else:
        data = dict(request.form)
        conditions = ["%s='%s'" % (k, v[0]) for k, v in data.items()]
        db.update(conditions, data['id'][0])

        return render_template('userone.html',
                               user=db.update_list(data['id'][0]))
Ejemplo n.º 3
0
def modify_pwd():
    if not session.get('name'):
        return redirect('/')
    if request.method == 'GET':
        id = request.args.get('id')
        return render_template('modify_pwd.html', user=db.update_list(id))
    else:
        data = dict(request.form)

        if data['newpassword'][0] != data['renewpassword'][0]:
            errmsg = 'The two passwords you typed do not match'
            return json.dumps({'code': '1', 'errmsg': errmsg})
        if not data['password'][0] or not data['newpassword'][0] or not data[
                'renewpassword'][0]:
            errmsg = 'password can not be null'
            return json.dumps({'code': '1', 'errmsg': errmsg})
        try:
            condition = [
                "%s='%s'" % ('password', v[0]) for k, v in data.items()
                if k == 'newpassword'
            ]
            db.update(condition, data['id'][0])
            if session.get('role'):
                return json.dumps({'code': '0', 'result': 'modify success!'})
            else:
                return redirect('/')
        except:
            errmsg = "modify failed"
            return json.dumps({'code': '1', 'errmsg': errmsg})
Ejemplo n.º 4
0
def modify_pwd():
    if not session.get('name'):
	return redirect('/')
    if request.method == 'GET':
        id = request.args.get('id')
	return render_template('modify_pwd.html',user = db.update_list(id))
    else:
	data = dict(request.form)
	
	if data['newpassword'][0] != data['renewpassword'][0]:
	    errmsg = 'The two passwords you typed do not match'
      	    return json.dumps({'code':'1','errmsg':errmsg})
	if not data['password'][0] or not data['newpassword'][0] or not data['renewpassword'][0]:
	    errmsg = 'password can not be null'
      	    return json.dumps({'code':'1','errmsg':errmsg})
	try:
            condition = [ "%s='%s'" %  ('password',v[0]) for k,v in data.items() if k == 'newpassword']
            db.update(condition,data['id'][0])
	    if session.get('role'):
        	return json.dumps({'code':'0','result':'modify success!'})
	    else:
	        return redirect('/')
	except:
            errmsg = "modify failed" 
	    return json.dumps({'code':'1','errmsg':errmsg})
Ejemplo n.º 5
0
def modify_pwd():
    if request.method == 'GET':
        id = request.args.get('id')
	return render_template('modify_pwd.html',user = db.update_list(id))
    else:
	data = dict(request.form)
	
	if data['newpassword'][0] != data['renewpassword'][0]:
	    errmsg = 'The two passwords you typed do not match'
	    return render_template('modify_pwd.html',result = errmsg)
	try:    
            condition = [ "%s='%s'" %  ('password',v[0]) for k,v in data.items() if k == 'newpassword']
            db.update(condition,data['id'][0])
	    return render_template('userone.html',user = db.update_list(data['id'][0]))
	except:
            errmsg = "modify failed" 
	    return render_template('modify_pwd.html',result = errmsg)
Ejemplo n.º 6
0
def modify_pwd():
    if request.method == 'GET':
        id = request.args.get('id')
        return render_template('modify_pwd.html', user=db.update_list(id))
    else:
        data = dict(request.form)

        if data['newpassword'][0] != data['renewpassword'][0]:
            errmsg = 'The two passwords you typed do not match'
            return render_template('modify_pwd.html', result=errmsg)
        try:
            condition = [
                "%s='%s'" % ('password', v[0]) for k, v in data.items()
                if k == 'newpassword'
            ]
            db.update(condition, data['id'][0])
            return render_template('userone.html',
                                   user=db.update_list(data['id'][0]))
        except:
            errmsg = "modify failed"
            return render_template('modify_pwd.html', result=errmsg)
Ejemplo n.º 7
0
def update():
    if not session.get('name'):
        return redirect('/')
    if request.method == 'GET':
        id = request.args.get('id')
        return render_template('update.html', user=db.update_list(id))
    else:
        data = dict(request.form)
        conditions = ["%s='%s'" % (k, v[0]) for k, v in data.items()]
        if session.get('role'):
            db.update(conditions, data['id'][0])
            return json.dumps({'code': '0', 'result': 'modify success!'})
        else:
            return redirect('/')
Ejemplo n.º 8
0
def update():
    if not session.get('name'):
	return redirect('/')
    if request.method=='GET':
        id = request.args.get('id')
	return render_template('update.html',user = db.update_list(id))
    else:
	data = dict(request.form)
        conditions = [ "%s='%s'" %  (k,v[0]) for k,v in data.items()]
	if session.get('role'):
            db.update(conditions,data['id'][0])
            return json.dumps({'code':'0','result':'modify success!'})
	else:
	    return redirect('/')