⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 courseord.py

📁 python web programming 部分
💻 PY
字号:
#
# $Workfile: CourseOrd.py $ $Revision: 3 $
# $Date: 10/07/01 1:36p $ $Author: Sholden $
#
import CourseBook
from dbsource import dbsource

conn = dbsource().conn
cursor = conn.cursor()


class ChkOut(CourseBook.Page):

    def Body(self):
        msg = """
        <P>If you already have an account you may
        proceed to <a href="/CrsOrder/">place your order.</A></P>
        <P>If you are not currently an account holder
        then you may
        <a href="/NewAccount/PythonTeach/">create one now</a>.
        <B>If you need to open an account, your order
        will NOT be lost.</B></P>
        <P>You will receive an email, confirming your account
        details and explaining how to finalize the order.</P>
        """
        return msg+self.ViewCart(self.session._bookings, final=1)

class Order(CourseBook.Page):

    def Body(self):
        if not self.session._bookings:
            return """
            <P>No order details can be found to enter.</P>
            """
        eml = self.session._udata.StdEmail
        result = []
        booking = []
        invoice = 0
        for clsnum, typ in self.session._bookings:
            if self.Enrollment(eml, clsnum) or \
                self.WaitList(eml, clsnum):           # already subscribed
                cursor.execute("""
                    SELECT CrsTitle, LocName, ClsDate
                    FROM Course, Location, Class
                    WHERE Location.LocNum=Class.Locnum
                      AND Course.CrsNum=Class.CrsNum
                      AND Class.ClsNum=%s""", (clsnum, ))
                r = cursor.fetchall()
                CrsTitle, LocName, ClsDate = r[0]
                result.append("""
                <P><font size="-2">You are already
                waitlisted or enrolled for the %s
                class in %s on %s. No additional
                reservation was made.</font></P>
                """ % (CrsTitle, LocName, ClsDate.strftime("%b %d")))
            else:
                if typ == "E":
                    tblname = "Enrollment"
                    invoice = 1
                else:
                    tblname = "Waitlist"
                cursor.execute("""
                    INSERT INTO %s (StdEmail, ClsNum)
                    VALUES(%%s, %%s)""" % tblname,
                    (eml, clsnum))
                booking.append((clsnum, typ))
        conn.commit()
        if booking:
            result.append("""
            <P>The following places have been reserved for you:""")
            result.append(self.ViewCart(booking, final=1))
        if invoice:
            result.append("""
            <P>An invoice will be emailed to you
            at the end of our business day.</P>""")
        result.append("""
            <P>Thank you very much for your business.</P>""")
        self.session._bookings = [] # empty the cart
        return "\n".join(result)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -