當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。