Beispiel #1
0
def add_cs():
    '''
    创建解题员和客服
    '''
    if not current_user.is_authenticated():
        return redirect(url_for('general.index'))    
    if current_user.type == Admin.ADMIN_TYPE.ADMIN:
        form = RegisterForm()
        if not form.validate_on_submit():
            print form.errors
            return render_template('admin/add_cs.html', form=form, nav_user_manage='active')
        try:
            if form.user_type.data=='0':
                cs = Admin(form.email.data, form.passwd.data, form.qq.data)
                ret = AdminBiz.add_CS(cs)
            else:
                solver = Admin(form.email.data, form.passwd.data, form.qq.data)
                ret = AdminBiz.add_solver(solver)
            success(ret)
        except DaixieError as e:
            fail(e)
            return render_template('admin/add_cs.html', form=form, nav_user_manage='active')
        return render_template('admin/add_cs.html', form=form, nav_user_manage='active')     
    else:
        return redirect(url_for('general.index'))
Beispiel #2
0
def add_cs():
    '''
    创建解题员和客服
    '''
    if not current_user.is_authenticated():
        return redirect(url_for('general.index'))
    if current_user.type == Admin.ADMIN_TYPE.ADMIN:
        form = RegisterForm()
        if not form.validate_on_submit():
            print form.errors
            return render_template('admin/add_cs.html',
                                   form=form,
                                   nav_user_manage='active')
        try:
            if form.user_type.data == '0':
                cs = Admin(form.email.data, form.passwd.data, form.qq.data)
                ret = AdminBiz.add_CS(cs)
            else:
                solver = Admin(form.email.data, form.passwd.data, form.qq.data)
                ret = AdminBiz.add_solver(solver)
            success(ret)
        except DaixieError as e:
            fail(e)
            return render_template('admin/add_cs.html',
                                   form=form,
                                   nav_user_manage='active')
        return render_template('admin/add_cs.html',
                               form=form,
                               nav_user_manage='active')
    else:
        return redirect(url_for('general.index'))
Beispiel #3
0
def logout():
    '''
    注销
    '''
    try:
        AdminBiz.admin_logout()
    except DaixieError as e:
        fail(e)
    return redirect(url_for('.index'))
Beispiel #4
0
def delete_cs(id):
    '''
    delete cs
    '''
    if not current_user.is_authenticated():
        return redirect(url_for('general.index'))    
    cs = AdminBiz.get_admin_by_id(id)
    try:
        ret = AdminBiz.delete_CS(cs=cs)
    except DaixieError as e:
        fail(e) 
    success(ret)
    return redirect(url_for('.cs_list'))
Beispiel #5
0
def delete_cs(id):
    '''
    delete cs
    '''
    if not current_user.is_authenticated():
        return redirect(url_for('general.index'))
    cs = AdminBiz.get_admin_by_id(id)
    try:
        ret = AdminBiz.delete_CS(cs=cs)
    except DaixieError as e:
        fail(e)
    success(ret)
    return redirect(url_for('.cs_list'))
Beispiel #6
0
def create_order():
    '''
    创建订单
    '''
    if not current_user.is_authenticated():
        return redirect(url_for('general.index'))    
    form = OrderForm()
    if not form.validate_on_submit():
        return render_template('order/create.html', form=form, nav_order_manage='active')

    
    file = request.files['supp_info'] 
    if file :   
        if not allowed_file(file.filename):
            fail("file type error")
            return render_template('order/create.html', form=form, nav_order_manage='active')

    user = UserBiz.get_user_by_email(form.user_email.data)

    cs = AdminBiz.get_admin_by_email(form.cs_email.data)
    solverid = 0
    if form.solver_email.data:
        solver = AdminBiz.get_solver_by_email(form.solver_email.data)
        solverid = solver.id


    order = Order(user.id, cs.id, solverid, form.require_time.data, form.expect_time.data, 
        form.title.data, form.expect_hour.data, form.expect_order_price.data, form.grade.data, 0, \
        form.description.data, form.extra_item.data, form.extra_money.data, form.log.data)

    
    try:
        ret = OrderBiz.create_order(order)
    except DaixieError as e:
        fail(e)
        return render_template('order/create.html', form=form, nav_order_manage='active')   

    if file :
        order_id = order.id
        save_file_with_order_id(order_id, file)
        order.supp_info = secure_filename(file.filename)
    
    try:
        OrderBiz.edit_order(order)
    except DaixieError as e:
        fail(e)
        return render_template('order/create.html', form=form, nav_order_manage='active')

    success(ret)
    return redirect(url_for('.my_list'))
Beispiel #7
0
def edit_order_for_admin(id):
    if not current_user.is_authenticated() :
        return redirect(url_for('general.index'))    
    if current_user.type != Admin.ADMIN_TYPE.ADMIN:
        fail(u"用户权限不足")
        return redirect(url_for('general.index'))

    order = OrderBiz.get_order_by_id(id).first()
    form = AdminEditOrderForm(obj=order)
    if not form.validate_on_submit():
        return render_template('order/edit_order_for_admin.html', form=form, id=id, order=order, nav_order_manage='active')
    
    file = request.files['supp_info']    
    
    cs = AdminBiz.get_admin_by_email(form.cs_email.data)
    solver = AdminBiz.get_solver_by_email(form.solver_email.data)

    order.cs_id = cs.id
    order.solver_id = solver.id
    print "order status:", order.status, "form status :", form.status.data
    if order.status>=1 and order.status <= form.status.data:
        order.status = form.status.data
    order.require_time = form.require_time.data
    order.expect_time = form.expect_time.data
    order.title = form.title.data
    order.description = form.description.data
    order.log = form.log.data
    order.grade = form.grade.data
    order.expect_hour = form.expect_hour.data
    order.actual_hour = form.actual_hour.data
    order.extra_item = form.extra_item.data
    if order.status == '3' and form.actual_order_price.data != 0 and form.actual_order_price.data is not None:
        order.actual_order_price = form.actual_order_price.data

    if file:
        save_file_with_order_id(id, file)
        order.supp_info = secure_filename(file.filename)

    #修改订单
    try:
        ret = OrderBiz.edit_order(order)
        success(ret)
    except DaixieError as e:
        fail(e)
        return render_template('order/edit_order_for_admin.html', form=form, id=id, order=order, nav_order_manage='active')

    return redirect(url_for('admin.home'))
Beispiel #8
0
def j_search_cs():
    email = request.args.get('email', '')
    query = request.args.get('query', '')
    page = get_arg('page', 1)

    try:
        if email:
            cs = AdminBiz.get_cs_by_email(email)
            cs_pager = Pagination(None, 1, 1, 1, [cs])
        else:
            cs_pager = AdminBiz.get_by_like(query, 0, page, per_page=10)
    except DaixieError as e:
        return j_err(e)

    cs = [{'id': cs.email, 'text': cs.email} for cs in cs_pager.items if cs]

    return j_ok(u'搜索成功', items=cs, pages=cs_pager.pages)
Beispiel #9
0
def update_cs(id):
    '''
    update cs
    '''
    if not current_user.is_authenticated():
        return redirect(url_for('general.index'))    
    cs=AdminBiz.get_admin_by_id(id);
    form = AccountForm();
    if not form.validate_on_submit():
        return render_template('admin/update.html', form=form, id=id, type="CS", nav_user_manage='active')
    try:
        cs.passwd = form.passwd.data
        ret = AdminBiz.cs_commit_update(cs=cs)
    except DaixieError as e:
        fail(e)
        return redirect(url_for('.cs_list'))     
    success(ret)
    return redirect(url_for('.cs_list')) 
Beispiel #10
0
def cs_list():
    '''
    
    '''
    if current_user.type == Admin.ADMIN_TYPE.ADMIN:
        all_cs = AdminBiz.get_all_CS();
        all_user = UserBiz.get_all_user();
        return render_template('admin/cs_list.html', cs_list=all_cs, user_list=all_user, nav_user_manage='active')
    else:
        return redirect(url_for('general.index'))
Beispiel #11
0
def j_search_cs():
    email = request.args.get('email', '')
    query = request.args.get('query', '')
    page = get_arg('page', 1)

    try:
        if email:
            cs = AdminBiz.get_cs_by_email(email)
            cs_pager = Pagination(None, 1, 1, 1, [cs])
        else:
            cs_pager = AdminBiz.get_by_like(query, 0,page, per_page=10)
    except DaixieError as e:
        return j_err(e)

    cs = [{
    'id': cs.email,
    'text': cs.email
    } for cs in cs_pager.items if cs]

    return j_ok(u'搜索成功', items=cs, pages=cs_pager.pages)
Beispiel #12
0
def update_cs(id):
    '''
    update cs
    '''
    if not current_user.is_authenticated():
        return redirect(url_for('general.index'))
    cs = AdminBiz.get_admin_by_id(id)
    form = AccountForm()
    if not form.validate_on_submit():
        return render_template('admin/update.html',
                               form=form,
                               id=id,
                               type="CS",
                               nav_user_manage='active')
    try:
        cs.passwd = form.passwd.data
        ret = AdminBiz.cs_commit_update(cs=cs)
    except DaixieError as e:
        fail(e)
        return redirect(url_for('.cs_list'))
    success(ret)
    return redirect(url_for('.cs_list'))
Beispiel #13
0
def cs_list():
    '''
    
    '''
    if current_user.type == Admin.ADMIN_TYPE.ADMIN:
        all_cs = AdminBiz.get_all_CS()
        all_user = UserBiz.get_all_user()
        return render_template('admin/cs_list.html',
                               cs_list=all_cs,
                               user_list=all_user,
                               nav_user_manage='active')
    else:
        return redirect(url_for('general.index'))
Beispiel #14
0
def j_search_solvers():
	email = request.args.get('email', '')
	query = request.args.get('query', '')
	page = get_arg('page', 1)
	type = request.args.get('type', '')

	type = Admin.ADMIN_TYPE.SOLVER

	try:
		if email:
			user = AdminBiz.get_cs_by_email(email, type)
			users_pager = Pagination(None, 1, 1, 1, [user])
		else:
			users_pager = AdminBiz.get_by_like(query, type, page, per_page=10)
	except DaixieError as e:
		return j_err(e)

	users = [{
	'id': user.email,
	'text': user.email
	} for user in users_pager.items if user]

	return j_ok(u'搜索成功', items=users, pages=users_pager.pages)
Beispiel #15
0
def j_search_solvers():
    email = request.args.get('email', '')
    query = request.args.get('query', '')
    page = get_arg('page', 1)
    type = request.args.get('type', '')

    type = Admin.ADMIN_TYPE.SOLVER

    try:
        if email:
            user = AdminBiz.get_cs_by_email(email, type)
            users_pager = Pagination(None, 1, 1, 1, [user])
        else:
            users_pager = AdminBiz.get_by_like(query, type, page, per_page=10)
    except DaixieError as e:
        return j_err(e)

    users = [{
        'id': user.email,
        'text': user.email
    } for user in users_pager.items if user]

    return j_ok(u'搜索成功', items=users, pages=users_pager.pages)
Beispiel #16
0
def login():
    '''
    登录
    '''
    form = LoginForm()
    if not form.validate_on_submit():
        return render_template('general/login.html', form=form, nav_login='******')
    email = form.email.data
    passwd = form.passwd.data
    auto = form.auto.data

    admin = Admin(email, passwd)
    try:
        ret = AdminBiz.admin_login(admin, auto)
    except DaixieError as e:
        fail(e)
        return render_template('general/login.html', form=form, nav_login='******')
    success(ret)
    return redirect(url_for('.index'))
Beispiel #17
0
 def cs_email(self):
     from daixieadmin.biz.admin import AdminBiz
     cs = AdminBiz.get_admin_by_id(self.cs_id)
     return cs.email
Beispiel #18
0
def load_user(admin_id):
    return AdminBiz.get_admin_by_id(admin_id)
Beispiel #19
0
 def solver_email(self):
     from daixieadmin.biz.admin import AdminBiz
     solver = AdminBiz.get_admin_by_id(self.solver_id)
     print "solver_email", solver.email
     return solver.email
Beispiel #20
0
def load_user(admin_id):
    return AdminBiz.get_admin_by_id(admin_id)
Beispiel #21
0
 def cs_email(self):
     from daixieadmin.biz.admin import AdminBiz
     cs = AdminBiz.get_admin_by_id(self.cs_id)
     return cs.email
Beispiel #22
0
 def solver_email(self):
     from daixieadmin.biz.admin import AdminBiz
     solver = AdminBiz.get_admin_by_id(self.solver_id)
     print "solver_email",solver.email
     return solver.email