Ejemplo n.º 1
0
def admin_add_role():
    if request.method == "GET":
        return render_template('admin_add_permission.html')
    else:
        forms = AuthForm(request.form)
        if forms.validate():
            datas = forms.data
            add_common(db, Auth, **datas)
            data = {"msg": "添加成功", "status": "200"}
        else:
            data = {"msg": "表单验证失败", "status": "202"}
        return jsonify(data)
Ejemplo n.º 2
0
def admin_user_add():
    if request.method == "GET":
        return render_template('admin_user_add.html')
    else:
        forms = UserForm(request.form)
        if forms.validate():
            datas = forms.data
            datas['reg_time'] = datetime.strptime(datas['reg_time'],
                                                  '%Y-%m-%d %H:%M:%S.%f')
            datas = {**datas, 'is_super': 0}
            add_common(db, User, **datas)
            data = {"msg": "添加成功", "status": "200"}
        else:
            data = {"msg": "表单验证失败", "status": "202"}
        return jsonify(data)
Ejemplo n.º 3
0
def admin_edit_role():
    if request.method == "GET":
        ids = request.args.get('id', '')
        print(ids)
        if ids or ids != "":
            tasks = Auth.query.filter(Auth.id == int(ids)).first()
            return render_template('admin_edit_permission.html', data=tasks)
        else:
            tasks = Auth.query.filter(Auth.id == 1).first()
            return render_template('admin_edit_permission.html', data=tasks)
    else:
        forms = AuthForm(request.form)
        if forms.validate():
            datas = forms.data
            add_common(db, Auth, **datas)
            data = {"msg": "添加成功", "status": "200"}
        else:
            data = {"msg": "表单验证失败", "status": "202"}
        return jsonify(data)