Exemplo n.º 1
0
def update_order():
    if current_user is not None and current_user.is_privileged(UserType.staff):
        orderid = request.args.get("orderid", -1)
        if int(orderid) == -1:
            abort(404)
        elif int(orderid) == 0:
            abort(404)

        order = Orders.query.filter(Orders.orderid == orderid).first()
        if order is None:
            return render_template("error.html", message="查找不到与之匹配的订单")

        order.paytypename = PayType.getName(order.paytype)
        order.statusname = OrderStatus.getName(order.status)

        return render_template(
            "update_order.html",
            username=current_user.username,
            order=order,
            orderStatus=OrderStatus.getAll(),
            payTypes=PayType.getAll(),
            index=6,
        )
    else:
        abort(403)
Exemplo n.º 2
0
def userorders():
	if current_user is not None and current_user.is_privileged(UserType.registered):
		page = request.args.get("page", 1)
		if page < 1:
			page = 1

		# 暂时只考虑课程(ptype=1)
		data = Users.query.with_entities(Users.username, Users.name, Course.name, Orders.amount, Orders.income, Orders.status, Orders.paytype, Orders.orderid, Orders.operator, CourseSchedule.time)\
			.join(Orders, Orders.username == Users.username)\
			.filter(Users.uid == current_user.uid)\
			.filter(Orders.cid == Course.cid)\
			.filter(Orders.csid == CourseSchedule.csid)\
			.paginate(int(page), config.PAGE_ITEMS, False)

		orderDataList = []
		for item in data.items:
			orderData = {}

			orderData['username'] = item[0]
			orderData['name'] = item[1]
			orderData['coursename'] = item[2]
			orderData['amount'] = item[3]
			orderData['income'] = item[4]
			orderData['orderstatusname'] = OrderStatus.getName(item[5])
			orderData['paytpyename'] = PayType.getName(item[6])
			orderData['orderid'] = item[7]
			orderData['operator'] = item[8]
			orderData['schedulename'] = item[9]

			orderDataList.append(orderData)

		data.items = orderDataList
		return render_template('userorders.html', username=current_user.username, pagination=data)
	else:
		abort(403)
Exemplo n.º 3
0
def searchorders():
    if current_user is not None and current_user.is_privileged(UserType.staff):
        page = request.args.get("page", 1)
        if page < 1:
            page = 1

        username = request.args.get("username")
        pattern = "%" + username + "%"  # 支持模糊查询

        data = (
            Users.query.with_entities(
                Users.username,
                Users.name,
                Course.name,
                Orders.amount,
                Orders.income,
                Orders.status,
                Orders.paytype,
                Orders.orderid,
                Orders.operator,
                CourseSchedule.time,
            )
            .join(Orders, Orders.username == Users.username)
            .join(OrderItem, OrderItem.orderid == Orders.orderid)
            .filter(Users.username.like(pattern))
            .filter(OrderItem.pid == Course.cid)
            .filter(OrderItem.subid == CourseSchedule.csid)
            .paginate(int(page), config.PAGE_ITEMS, False)
        )

        orderDataList = []
        for item in data.items:
            orderData = {}

            orderData["username"] = item[0]
            orderData["name"] = item[1]
            orderData["coursename"] = item[2]
            orderData["amount"] = item[3]
            orderData["income"] = item[4]
            orderData["orderstatusname"] = OrderStatus.getName(item[5])
            orderData["paytpyename"] = PayType.getName(item[6])
            orderData["orderid"] = item[7]
            orderData["operator"] = item[8]
            orderData["schedulename"] = item[9]

            orderDataList.append(orderData)

        data.items = orderDataList

        return render_template("orders.html", username=current_user.username, pagination=data, index=6)
    else:
        abort(403)
Exemplo n.º 4
0
def course_userregister():
	if current_user is not None and current_user.is_privileged(UserType.registered):
		cid = request.args.get('cid', -1)
		csid = request.args.get('csid', -1)
		if csid < 0:
			return render_template('error.html', message='查找不到与之匹配的课程班次')

		courseSchedule = CourseSchedule.query.filter(CourseSchedule.csid == csid).first()
		if courseSchedule is None:
			return render_template('error.html', message='查找不到与之匹配的课程班次')

		course = Course.query.filter(Course.cid==cid).first()
		if course is None:
			return render_template('error.html', message='查找不到与之匹配的课程')
		else:
			count = CourseStudent.query.filter(CourseStudent.cid==cid, CourseStudent.csid==csid).count()
			teachernames = ""
			mteacher = Teacher.query.filter(Teacher.tid == courseSchedule.mteacher).first();
			muser = Users.query.filter(Users.username==mteacher.username).first()
			if muser:
				teachernames = muser.getName() # 

			if(len( teachernames ) > 0):
				teachernames += " "

			bteacher = Teacher.query.filter(Teacher.tid == courseSchedule.bteacher).first();
			if bteacher:
				buser = Users.query.filter(Users.username==bteacher.username).first()
				if buser:
					teachernames += buser.getName()

			return render_template('register_usercourse.html',\
				username=current_user.username,\
				course=course,\
				courseSchedule = courseSchedule, \
				studentCount=count, \
				pays=PayType.getAllSupported(), \
				teachernames = teachernames, \
				amount = course.charge)
	else:
		flash(u'您需要登录后才能访问该页面')
		return redirect(url_for('login'))
Exemplo n.º 5
0
def register_course():
    if current_user is not None and current_user.is_privileged(UserType.staff):
        cid = request.args.get("cid")
        username = request.args.get("username")

        course = Course.query.filter(Course.cid == cid).first()
        user = Users.query.filter(Users.username == username).first()
        if course is None:
            return render_template("error.html", message="查找不到与之匹配的课程")
        elif user is None:
            return render_template("error.html", message="查找不到与之匹配的用户")
        else:
            status = CourseStatus.getName(course.status)
            teacher = Teacher.query.filter(Teacher.tid == course.tid).first()
            allteachers = Teacher.query.order_by(Teacher.tid).all()
            return render_template(
                "register_course.html", username=current_user.username, course=course, pays=PayType.getAll()
            )
    else:
        abort(403)