当前位置: 首页>>代码示例>>Python>>正文


Python Ticket.expires方法代码示例

本文整理汇总了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()
开发者ID:HughePaul,项目名称:Website,代码行数:59,代码来源:utils.py

示例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()
开发者ID:Jonty,项目名称:Website,代码行数:53,代码来源:utils.py


注:本文中的models.Ticket.expires方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。