本文整理汇总了Python中models.Ticket.expires方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.expires方法的具体用法?Python Ticket.expires怎么用?Python Ticket.expires使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Ticket
的用法示例。
在下文中一共展示了Ticket.expires方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_test_user
# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import expires [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 expires [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()