Пример #1
0
def populate(dbc):
    
    pizzeria.populate(dbc)
    
    SERV = dbc.query(Service)
    CUST = dbc.query(pizzeria.Customer)
    ORDERS = dbc.query(pizzeria.Order)
    PROD = dbc.query(pizzeria.Product)
    
    s1 = SERV.appendRow(name="bring home",price=1)
    s2 = SERV.appendRow(name="organize party",price=100)
    c3 = CUST.appendRow(name="Bernard")

    o1 = ORDERS.appendRow(customer=c3,date=itod(20040318))
    q = o1.lines()
    q.appendRow(product=PROD.peek(1),qty=1)
    q.appendRow(product=s1,qty=1)
    
    o2 = ORDERS.appendRow(customer=CUST.peek(1),date=itod(20040319))
    q = o2.lines()
    q.appendRow(product=PROD.peek(1),qty=2)
    q.appendRow(product=PROD.peek(2),qty=3)

    o1.register()
    o2.register()
Пример #2
0
    def test04(self):
        SERV = self.sess.query(Service)
        CUST = self.sess.query(Customer)
        PROD = self.sess.query(Product)
        ORDERS = self.sess.query(Order)
        LINES = self.sess.query(OrderLine)
        #db = self.db
        pizzeria.populate(self.sess)
        
        s1 = SERV.appendRow(name="bring home",price=1)
        s2 = SERV.appendRow(name="organize party",price=100)
        c3 = CUST.appendRow(name="Bernard")

        p1 = PROD.peek(1)
        p2 = PROD.peek(2)

        o1 = ORDERS.appendRow(customer=c3,date=itod(20040318))
        q = o1.lines()
        q.appendRow(product=s1,qty=1)
        q.appendRow(product=p1,qty=1)

        o2 = ORDERS.appendRow(customer=CUST[1],
                              date=itod(20040319))
        q = o2.lines()
        q.appendRow(product=p1,qty=2)
        q.appendRow(product=p2,qty=3)
        #LINES.appendRow(order=o1,product=s2,qty=1)

        #db.commit()

        q = o1.lines("product qty")
        
        totalPrice = 0
        for line in q:
            #print line.product.name, line.qty
            totalPrice += (line.qty * line.product.price)
            
        o1.register()
        o2.register()

        self.sess.commit()
Пример #3
0
    def test04(self):
        SERV = self.sess.query(Service)
        CUST = self.sess.query(Customer)
        PROD = self.sess.query(Product)
        ORDERS = self.sess.query(Order)
        LINES = self.sess.query(OrderLine)
        #db = self.db
        pizzeria.populate(self.sess)

        s1 = SERV.appendRow(name="bring home", price=1)
        s2 = SERV.appendRow(name="organize party", price=100)
        c3 = CUST.appendRow(name="Bernard")

        p1 = PROD.peek(1)
        p2 = PROD.peek(2)

        o1 = ORDERS.appendRow(customer=c3, date=itod(20040318))
        q = o1.lines()
        q.appendRow(product=s1, qty=1)
        q.appendRow(product=p1, qty=1)

        o2 = ORDERS.appendRow(customer=CUST[1], date=itod(20040319))
        q = o2.lines()
        q.appendRow(product=p1, qty=2)
        q.appendRow(product=p2, qty=3)
        #LINES.appendRow(order=o1,product=s2,qty=1)

        #db.commit()

        q = o1.lines("product qty")

        totalPrice = 0
        for line in q:
            #print line.product.name, line.qty
            totalPrice += (line.qty * line.product.price)

        o1.register()
        o2.register()

        self.sess.commit()
Пример #4
0
from lino.apps.pizzeria.pizzeria import Pizzeria, populate, Order

app = Pizzeria() 

dbc = app.createContext()
    
populate(dbc)

orders = dbc.query(Order,"customer totalPrice")

for o in orders:
    print "%s must pay %d EUR" % (o.customer.name, o.totalPrice)

del app, dbc, orders, o
Пример #5
0
from lino.apps.pizzeria.pizzeria import Pizzeria, populate, Order

app = Pizzeria() 

dbc = app.createContext()
    
populate(dbc)

orders = dbc.query(Order,"customer totalPrice")

for o in orders:
    print "%s must pay %d EUR" % (o.customer.name, o.totalPrice)

del app, dbc, orders, o