def get(self, id): order = model.order_get(id) if order is None: webapp2.abort(404) coupons = model.order_find_coupons(order.order_id) coupon_urls = map(lambda c: webapp2.uri_for('coupon', id=c.coupon_id), coupons) values = {'order': order, 'coupons': zip(coupons, coupon_urls)} write_template(self.response, 'accept.html', values)
def test_order_find_coupons(self): # We need to see results of order_process immediately in this test self.cpolicy.SetProbability(1.0) # Create two orders and process successful payment ct = model.CouponType('test', 300.0, "Test flight") order1 = model.order_create('1', ct, test=True) model.order_process(order1.order_id, '*****@*****.**', 100.0, 'EUR') order2 = model.order_create('2', ct, test=True) model.order_process(order2.order_id, '*****@*****.**', 100.0, 'EUR') coupons = model.order_find_coupons(order1.order_id) self.assertEqual(len(coupons), 1) self.assertEqual(coupons[0].order.order_id, order1.order_id)