def my_list_page(page=1): ''' 查看所有订单 ''' if not current_user.is_authenticated(): raise u'权限不足' pager = None if current_user.type == Admin.ADMIN_TYPE.CS: pager = OrderBiz.get_order_list_by_admin_id(current_user.id, page) if current_user.type == Admin.ADMIN_TYPE.SOLVER: pager = OrderBiz.get_order_list_by_solver_id(current_user.id, page) return render_template('order/morelist.html', my_list =pager, paginate=True, nav_order_manage='active', tpye=1)
def my_list(page=1): ''' 查看我的所有订单 ''' if not current_user.is_authenticated(): return redirect(url_for('general.index')) searchform = SearchForm() pager = None if current_user.type == Admin.ADMIN_TYPE.CS or current_user.type == Admin.ADMIN_TYPE.ADMIN: pager = OrderBiz.get_order_list_by_admin_id(current_user.id, page=1) if current_user.type == Admin.ADMIN_TYPE.SOLVER: pager = OrderBiz.get_order_list_by_solver_id(current_user.id, page=1) return render_template('order/list.html',searchform = searchform, my_list =pager, type=1, nav_order_manage='active')
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'))
def due_order(page=0): ''' ''' if not current_user.is_authenticated(): return redirect(url_for('general.index')) searchform = SearchForm() if page == 0: pager = None pager = OrderBiz.get_due_order_by_pager(1) return render_template('order/list.html', searchform = searchform, order_list=pager, type=2, nav_order_manage='active') else : pager = None pager = OrderBiz.get_due_order_by_pager(page) return render_template('order/morelist.html', searchform = searchform, order_list=pager, type=2, nav_order_manage='active')
def search_order(): if not current_user.is_authenticated(): return redirect(url_for('general.index')) searchform = SearchForm() print "order : ",searchform.order_id.data, "solver :", searchform.solver_id.data result = OrderBiz.search_order_by_pager(1,searchform.order_id.data,searchform.solver_id.data,searchform.require_time.data) return render_template('order/list.html', searchform = searchform, order_list=result, type=type, nav_order_manage='active')
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'))
def order_list_page(page=1): ''' 查看所有订单 ''' if not current_user.is_authenticated(): raise u'权限不足' pager = None pager = OrderBiz.get_order_list_by_pager(page) return render_template('order/morelist.html', order_list=pager, paginate=True, nav_order_manage='active')
def edit_order_for_cs(id): if not current_user.is_authenticated(): return redirect(url_for('general.index')) if current_user.type != Admin.ADMIN_TYPE.CS: fail(u"用户权限不足") return redirect(url_for('general.index')) order = OrderBiz.get_order_by_id(id).first() form = CSEditOrderForm(obj=order) form.log.data = '' if not form.validate_on_submit(): print "show order editing" return render_template('order/edit_order_for_cs.html', form=form, id= id, order=order, nav_order_manage='active') file = request.files['supp_info'] if order.status>='1' and order.status <= form.status.data: order.status = form.status.data order.expect_time = form.expect_time.data order.title = form.title.data order.description = form.description.data order.log = order.log+form.log.data order.grade = form.grade.data order.expect_hour = form.expect_hour.data order.actual_hour = form.actual_hour.data if order.status == '3' and form.actual_order_price.data != 0 and form.actual_order_price is not None: order.actual_order_price = form.actual_order_price.data if file: save_file_with_order_id(id, file) print file.name 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_cs.html', form=form, id=id, order=order, nav_order_manage='active') return redirect(url_for('admin.home'))
def more_info(id): if not current_user.is_authenticated(): fail(u'权限不足') return redirect(url_for('general.index')) order = OrderBiz.get_order_by_id(id).first() if current_user.type == Admin.ADMIN_TYPE.CS: return render_template('order/more_info_for_cs.html', order=order, nav_order_manage='active') if current_user.type == Admin.ADMIN_TYPE.ADMIN: return render_template('order/more_info_for_admin.html', order=order, nav_order_manage='active') if current_user.type == Admin.ADMIN_TYPE.SOLVER: return render_template('order/more_info_for_solver.html', order=order, nav_order_manage='active')
def order_list(page=1): ''' 查看所有订单 ''' if not current_user.is_authenticated(): return redirect(url_for('general.index')) searchform = SearchForm() pager = None pager = OrderBiz.get_order_list_by_pager(page) return render_template('order/list.html', searchform = searchform, order_list=pager, type=0, nav_order_manage='active')
def download_file(id): order = OrderBiz.get_order_by_id(id).first() filename = order.supp_info path = app.config['DIR_RESOURCES'] +'/'+ str(id) +'/' print "file to be downloaded is at : ", path return send_from_directory(path, filename, as_attachment=True)