本文整理匯總了Python中models.Ticket.payment方法的典型用法代碼示例。如果您正苦於以下問題:Python Ticket.payment方法的具體用法?Python Ticket.payment怎麽用?Python Ticket.payment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Ticket
的用法示例。
在下文中一共展示了Ticket.payment方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: make_test_user
# 需要導入模塊: from models import Ticket [as 別名]
# 或者: from models.Ticket import payment [as 別名]
def make_test_user(self):
try:
user = User.query.filter(User.email == "[email protected]").one()
except NoResultFound:
user = User('[email protected]', 'testuser')
user.set_password('happycamper')
db.session.add(user)
amounts = {
"prepayfull" : TicketType.query.filter(TicketType.name == 'Full Camp Ticket (prepay)').one().cost,
"full" : TicketType.query.filter(TicketType.name == 'Full Camp Ticket').one().cost
}
#
# TODO: needs to cover:
#
# single full ticket, no prepay
# single full ticket with prepay
# multiple full tickets, no prepay
# multiple full tickets, with prepay
# multiple full tickets, some prepay
#
# kids & campervans?
#
# full, prepay
for full, pp in ((1,0), (0,1), (3,0), (0,3), (2,1)):
for pt in (BankPayment, GoCardlessPayment, GoogleCheckoutPayment):
total = (full * amounts['full']) + (pp * amounts['prepayfull'])
payment = pt(total)
payment.state = "inprogress"
if payment.provider == "gocardless":
payment.gcid = "%3dSDJADG" % (int(random.random() * 1000 ))
sess.add(payment)
tt = 'Full Camp Ticket'
for i in range(full):
t = Ticket(type_id = TicketType.query.filter(TicketType.name == tt).one().id)
t.payment = payment
t.expires = datetime.utcnow() + timedelta(days=app.config.get('EXPIRY_DAYS'))
user.tickets.append(t)
tt = 'Full Camp Ticket (prepay)'
for i in range(pp):
t = Ticket(type_id = TicketType.query.filter(TicketType.name == tt).one().id)
t.payment = payment
t.expires = datetime.utcnow() + timedelta(days=app.config.get('EXPIRY_DAYS'))
user.tickets.append(t)
user.payments.append(payment)
db.session.commit()
self.user = user
print user.name
for p in user.payments.all():
print p.provider, p.amount
print p.tickets.all()
示例2: make_test_user
# 需要導入模塊: from models import Ticket [as 別名]
# 或者: from models.Ticket import payment [as 別名]
def make_test_user(self):
try:
user = User.query.filter(User.email == "[email protected]").one()
except NoResultFound:
user = User('[email protected]', 'testuser')
user.set_password('happycamper')
db.session.add(user)
types = {
"full" : TicketType.query.get('full')
}
#
# FIXME: this is a complete mess
#
# TODO: needs to cover:
#
# single full ticket
# multiple full tickets
#
# kids & campervans?
#
# full
for full in ([1], [0], [3], [0], [2]):
for pt in (BankPayment, GoCardlessPayment):
for curr in ['GBP', 'EUR']:
total = (full * amounts['full'].get_price(curr))
payment = pt(curr, total)
payment.state = "inprogress"
if payment.provider == "gocardless":
payment.gcid = "%3dSDJADG" % (int(random.random() * 1000 ))
sess.add(payment)
for i in range(full):
t = Ticket(code='full')
t.payment = payment
if payment.currency == 'GBP':
t.expires = datetime.utcnow() + timedelta(days=app.config['EXPIRY_DAYS_TRANSFER'])
elif payment.currency == 'EUR':
t.expires = datetime.utcnow() + timedelta(days=app.config['EXPIRY_DAYS_TRANSFER_EURO'])
user.tickets.append(t)
user.payments.append(payment)
db.session.commit()
self.user = user
print user.name
for p in user.payments.all():
print p.provider, p.amount
print p.tickets.all()