コード例 #1
0
def userlist():
    if not session.get('username'):
        return redirect('/login')
    sess = dict(session)
    if sess['role'] != '1' and sess['username']:
        users = mysql.user_one(sess['username'])
        return render_template('userlist.html', users=users, sess=sess)
    else:
        users = mysql.users_all()
        return render_template('userlist.html', users=users, sess=sess)
コード例 #2
0
def userlist():
    if request.method == 'POST':
        sel = request.form['cats']
        users = mysql.get_all(sel)
        return render_template('userlist.html', users=users)
    else:
        names = request.args.get('name')
        if names:
            users = mysql.user_one(names)
            return render_template('userlist.html', users=users)
        else:
            users = mysql.users_all()
            return render_template('userlist.html', users=users)
コード例 #3
0
def userlist():
    if request.method == 'POST':
        sel = request.form['cats']
        users = mysql.get_all(sel)
        return render_template('userlist.html', users=users)
    else:
        names = request.args.get('name')
        if names:
            users = mysql.user_one(names)
            return render_template('userlist.html', users=users)
        else:
            users = mysql.users_all()
            return render_template('userlist.html', users=users)
コード例 #4
0
def userlist():
    if not session.get('username'):
        return redirect('/login')
    sess = dict(session)
    if request.method == 'POST':
            sel = request.form['cats']
            users = mysql.get_all(sel,sess['role'])
            return render_template('userlist.html', users=users, sess=sess)
    else:
        if sess['role'] != '1' and sess['username']:
            users = mysql.user_one(sess['username'])
            return render_template('userlist.html', users=users, sess=sess)
        else:
            users = mysql.users_all()
            return render_template('userlist.html', users=users, sess=sess)
コード例 #5
0
def userlist():
    if not session.get('username'):
        return redirect('/login')
    sess = dict(session)
    if request.method == 'POST':
        sel = request.form['cats']
        users = mysql.get_all(sel, sess['role'])
        return render_template('userlist.html', users=users, sess=sess)
    else:
        if sess['role'] != '1' and sess['username']:
            users = mysql.user_one(sess['username'])
            return render_template('userlist.html', users=users, sess=sess)
        else:
            users = mysql.users_all()
            return render_template('userlist.html', users=users, sess=sess)
コード例 #6
0
def add():
    error = 'Account already exists'
    error1 = 'passwd error'
    if request.method == 'POST':
        d_user = dict(request.form)
        d = {k: v[0] for k, v in d_user.iteritems()}
        user_list = mysql.users_all()
        for user in user_list:
            if d['name'] in user['name']:
                return render_template('add.html', error=error)
        if d['password'] != d['re_password']:
            return render_template('add.html', error=error1)
        else:
            if d['role'] == '1':
                mysql.insert_user(d)
                return redirect('/userlist')
            else:
                mysql.insert_user(d)
                return redirect('/userlist?name=%s' % (d['name']))
    else:
        return render_template('add.html')
コード例 #7
0
def add():
    error = 'Account already exists'
    error1 = 'passwd error'
    if request.method == 'POST':
        d_user = dict(request.form)
        d = {k: v[0] for k, v in d_user.iteritems()}
        user_list = mysql.users_all()
        for user in user_list:
            if d['name'] in user['name']:
                return render_template('add.html', error=error)
        if d['password'] != d['re_password']:
            return render_template('add.html', error=error1)
        else:
            if d['role'] == '1':
                mysql.insert_user(d)
                return redirect('/userlist')
            else:
                mysql.insert_user(d)
                return redirect('/userlist?name=%s' % (d['name']))
    else:
        return render_template('add.html')
コード例 #8
0
def add():
    if not session.get('username'):
        return redirect('/login')
    sess = dict(session)
    if request.method == 'POST':
        d_user = dict(request.form)
        d = {k: v[0] for k, v in d_user.iteritems()}
        if d['name'] == '' or d['password'] == '' or d[
                're_password'] == '' or d['email'] == '' or d['mobile'] == '':
            return jsonify({'code': 3, 'errmsg': '不能为空'})
        user_list = mysql.users_all()
        for user in user_list:
            if d['name'] in user['name']:
                return jsonify({'code': 2, 'errmsg': '用户已存在'})
        if d['password'] != d['re_password']:
            return jsonify({'code': 1, 'errmsg': '两次密码不相同'})
        else:
            mysql.insert_user(d)
            return jsonify({'code': 0, 'result': '添加用户成功'})
    else:
        return jsonify({'sess': sess})
コード例 #9
0
def add():
    if not session.get('username'):
        return redirect('/login')
    error = 'Account already exists'
    error1 = 'passwd error'
    error2 = 'User name and Chinese name can not be the same'
    if request.method == 'POST':
        d_user = dict(request.form)
        d = {k: v[0] for k, v in d_user.iteritems()}
        user_list = mysql.users_all()
        for user in user_list:
            if d['name'] in user['name']:
                return render_template('add.html', error=error)
        if d['password'] != d['re_password']:
            return render_template('add.html', error=error1)
        elif d['name'] == d['name_cn']:
            return render_template('add.html', error=error2)
        else:
            mysql.insert_user(d)
            return redirect('/userlist')
    else:
        return render_template('add.html')
コード例 #10
0
def add():
    if not session.get('username'):
        return redirect('/login')
    error = 'Account already exists'
    error1 = 'passwd error'
    error2 = 'User name and Chinese name can not be the same'
    if request.method == 'POST':
        d_user = dict(request.form)
        d = {k: v[0] for k, v in d_user.iteritems()}
        user_list = mysql.users_all()
        for user in user_list:
            if d['name'] in user['name']:
                return render_template('add.html', error=error)
        if d['password'] != d['re_password']:
            return render_template('add.html', error=error1)
        elif d['name'] == d['name_cn']:
            return render_template('add.html', error=error2)
        else:
            mysql.insert_user(d)
            return redirect('/userlist')
    else:
        return render_template('add.html')