• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Ticket类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Ticket的典型用法代码示例。如果您正苦于以下问题:Python Ticket类的具体用法?Python Ticket怎么用?Python Ticket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Ticket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: update_token

def update_token():
  print 'update access token'
  params = {
    'grant_type': 'client_credential',
    'appid': APPID,
    'secret': APPSECRET
  }
  host = 'api.weixin.qq.com'
  path = '/cgi-bin/token'
  method = 'GET'
 
  res = send_request(host, path, method, params=params)
  if not res[0]:
    return False
  if res[1].get('errcode'):
    return False
  token = res[1].get('access_token')
  starttime = timezone.now()
  expires_in = timedelta(seconds=int(res[1].get('expires_in')))
  endtime = starttime + expires_in
  token_record = Ticket.objects.filter(ticket_type=1).order_by('-start_time')
  if len(token_record) > 0:
    token_record = token_record[0]
  else:
    token_record = Ticket()
  token_record.content = token
  token_record.end_time = endtime
  token_record.save()
  return token_record
开发者ID:,项目名称:,代码行数:29,代码来源:


示例2: testReSellCancelledTicket

    def testReSellCancelledTicket(self):
        """
        TODO
        """
        ticket = Ticket(night=self.night, sector=self.sector, row=1,
                        sit=5, public_type=self.pt)
        ticket.save()

        sell = Sell(sell_point=self.sell_point)
        sell.save()

        ticket_sell = TicketSell(sell=sell, ticket=ticket)
        ticket_sell.save()

        self.assertEquals(True, ticket.was_selled)

        cancellation = Cancellation(ticket=ticket)
        cancellation.save()

        self.assertEquals(False, ticket.was_selled)

        sell = Sell(sell_point=self.sell_point)
        sell.save()

        ticket_sell = TicketSell(sell=sell, ticket=ticket)
        ticket_sell.save()

        self.assertEquals(True, ticket.was_selled)
开发者ID:ariel17,项目名称:bandfestival,代码行数:28,代码来源:tests.py


示例3: getTicketForUser

def getTicketForUser(userRequestingTicket):
  currentTickets = Ticket.objects.filter(user=userRequestingTicket)
  if currentTickets:
    for ticket in currentTickets:
      ticket.delete()
  toReturn = Ticket(user=userRequestingTicket, ticket_hash=getUniqueRandHash())
  toReturn.save()
  return toReturn 
开发者ID:fiendskull9,项目名称:UDJ,代码行数:8,代码来源:auth.py


示例4: setUp

    def setUp(self):
        """
        TODO
        """
        stadium = Stadium(name="test stadium")
        stadium.save()

        self.sector = Sector(stadium=stadium, letter="A", color="#00ff00",
                             rows=10, sits=10, price=Decimal("10.00"))
        self.sector.save()

        self.festival = Festival(stadium=stadium, name="test festival",
                                 base_price=Decimal("10.00"))
        self.festival.save()

        start_night = datetime.now() + timedelta(days=50)

        self.night = Night(festival=self.festival, datetime=start_night)
        self.night.save()

        for i in range(2):
            band = Band(name="Test band %d" % i)
            band.save()

            self.bbn = BandByNight(band=band, night=self.night,
                                   price=Decimal("5.00"))
            self.bbn.save()

        self.pt = PublicType(name="maxor", price=Decimal("10.00"))
        self.pt.save()

        self.discount = Discount(festival=self.festival, limit_days=30,
                                 porcent=Decimal("10.00"))
        self.discount.save()

        self.ticket1 = Ticket(night=self.night, sector=self.sector, row=1,
                              sit=1, public_type=self.pt)
        self.ticket1.save()

        self.ticket2 = Ticket(night=self.night, sector=self.sector, row=1,
                              sit=2, public_type=self.pt)
        self.ticket2.save()

        self.sell_center = SellCenter(name="Test sell center")
        self.sell_center.save()

        self.sell_point = SellPoint(sell_center=self.sell_center)
        self.sell_point.save()

        self.sell = Sell(sell_point=self.sell_point)
        self.sell.save()

        ticket_sell = TicketSell(sell=self.sell, ticket=self.ticket1)
        ticket_sell.save()

        ticket_sell = TicketSell(sell=self.sell, ticket=self.ticket2)
        ticket_sell.save()
开发者ID:ariel17,项目名称:bandfestival,代码行数:57,代码来源:tests.py


示例5: create_node

def create_node(request, parent_id, title):
    try:
        parent_node = Ticket.objects.get(id=parent_id)
    except Exception as e:
        return HttpResponse(str(e), status = 400)

    node = Ticket(parent = parent_node, title = title)
    node.save()
    return HttpResponse('{"id":'+str(node.id)+'}', content_type="application/json")
开发者ID:nviel,项目名称:issuestree,代码行数:9,代码来源:views.py


示例6: make_some_db

    def make_some_db():
        """Create fake data for test"""
        day = 27
        date = datetime.datetime(year=2017, month=1, day=10,
                                 hour=0, minute=0, second=0)
        td = datetime.timedelta
        # type = ['standard', 'save', 'flex']
        # type_bu = ['standard', 'flex']
        # carry = ['Ppew', 'UFO', 'Aiur', 'Navi', 'Medin', 'Lotha', 'Sinvo',
        #          'Valve', 'Volvo', 'Skys']
        carry = ['vna', 'vja', 'jsa']
        # sit_class = ['economy', 'business', 'first', 'save']

        ap = Airport.objects.get
        rc = random.choice
        rr = random.randrange
        for x in xrange(1, 2):
            print 'make_tk', x
            in1 = 11  # rr(1, 21)
            in2 = 14  # rr(1, 21)
            while in2 == in1:
                in2 = rr(1, 21)
            td1 = td(hours=16, minutes=35)
            td2 = td1 + td(hours=17, minutes=35)
            # sit = rc(sit_class)
            # typ = rc(type)
            # if sit == 'first' or sit == 'save':
            #     typ = None
            # elif sit == 'business' and typ == 'save':
            #     typ = 'standard'
            pr1 = rr(1, 300)
            # pr2 = pr1 - 100 * rr(3, 5) if pr1 > 600 else pr1 - 100 * rr(1, 2)
            # pr3 = 0 if typ == 'save' else 100*rr(1,2)
            # ft1 = pr1*38/100
            # ft2 = pr2*29/100
            # ft3 = 100*rr(0, 1) + pr3*1/10

            carrier = rc(carry)
            f_code_num = rr(12, 89)*10
            if carrier == 'vja':
                f_code = 'VJ' + str(f_code_num)
            if carrier == 'jsa':
                f_code = 'JS' + str(f_code_num)
            if carrier == 'vna':
                f_code = 'VN' + str(f_code_num)

            t = Ticket(departure_port=ap(pk=in1),
                       arrival_port=ap(pk=in2),
                       departure_time=date + td1,
                       arrival_time=date + td2,
                       ticket=pr1,
                       carrier=carrier,
                       flight_code=f_code,
                       date_created=timezone.now()
                       )
            t.save()
开发者ID:Artielkami,项目名称:Get2Travel,代码行数:56,代码来源:dataAdapter.py


示例7: get

    def get(self, request):
        service = request.GET.get(SERVICE_PARAM)
        renew = request.GET.get(RENEW_PARAM) is not None
        gateway = request.GET.get(GATEWAY_PARAM) is not None

        if not service:
            return self.failure(request, '', 'no service field')
        model = Service.objects.for_service(service)
        if not model:
            return self.failure(request, service, 'service unknown')
        if renew and gateway:
            return self.failure(request, service, 'renew and gateway cannot be requested '
                    'at the same time')

        st = Ticket()
        st.service = model
        st.service_url = service
        st.renew = renew
        self.logger.debug('login request from %r renew: %s gateway: %s',
                service, renew, gateway)
        if self.must_authenticate(request, renew, gateway):
            st.save()
            return self.authenticate(request, st)
        self.validate_ticket(request, st)
        if st.valid():
            st.save()
            return redirect(request, service, params={'ticket': st.ticket_id})
        self.logger.debug('gateway requested but no session is open')
        return redirect(request, service)
开发者ID:josuebrunel,项目名称:authentic2,代码行数:29,代码来源:views.py


示例8: new_contact_ticket

def new_contact_ticket(request):
    ticket_created = False
    if request.POST:
        form = __get_contact_form(request)
        if form.is_valid():
            ticket = Ticket()
            ticket.title = form.cleaned_data['title']
            ticket.source = TICKET_SOURCE_CONTACT_FORM
            ticket.status = TICKET_STATUS_NEW
            ticket.queue = Queue.objects.get(name=QUEUE_SUPPORT_REQUESTS)
            tc = TicketComment()
            if request.user.is_authenticated():
                ticket.sender = request.user
                tc.sender = request.user
            else:
                ticket.sender_email = form.cleaned_data['email']
            tc.text = form.cleaned_data['message']
            ticket.save()
            tc.ticket = ticket
            tc.save()
            ticket_created = True
            # TODO: send email
    else:
        form = __get_contact_form(request, False)
    return render_to_response('tickets/contact.html', locals(), context_instance=RequestContext(request))
开发者ID:takuya1981,项目名称:freesound,代码行数:25,代码来源:views.py


示例9: make_test_user

  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,代码行数:51,代码来源:utils.py


示例10: test_new_ticket_linked_sound

 def test_new_ticket_linked_sound(self):
     test_user = User.objects.get(username='test_user')
     ticket = Ticket()
     ticket.status = 'new'
     ticket.sender = User.objects.get(username='test_user')
     ticket.assignee = User.objects.get(username='test_moderator')
     ticket.queue = Queue.objects.get(name=QUEUE_SOUND_MODERATION)
     ticket.save()
     # just to test, this would be a sound object for example
     s = Sound(description='test sound', license_id=1, user=test_user)
     s.save()
     ticket.sound = s
     ticket.save()
     self.assertEqual(s.id, ticket.sound.id)
开发者ID:,项目名称:,代码行数:14,代码来源:


示例11: run

    def run(self):
        tt = TicketType.query.filter_by(fixed_id=24).one()

        for i in range(1, 50 + 1):
            email = 'user_%[email protected]' % i
            if not User.query.filter_by(email=email).first():
                u = User(email, 'Parking ticket %s' % i)
                db.session.add(u)
                db.session.commit()

                t = Ticket(u.id, tt)
                t.paid = True
                t.emailed = True

        db.session.commit()
开发者ID:,项目名称:,代码行数:15,代码来源:


示例12: book_ticket

def book_ticket():
    if 'user_id' not in session:
        return login_in_please()
    user_id = session['user_id']

    req = request.get_json()
    if 'type' not in req:
        return bad_request()
    ticket_type = req['type']

    if ticket_type not in app.config['TYPE_IDS'].values():
        return bad_request()
    seat_num = None
    if ticket_type == app.config['TYPE_IDS']['pc']:
        if 'seat' not in req:
            return bad_request()
        seat_num = req['seat']

    tickets_max = app.config['TICKETS_MAX']
    price = app.config['PRICING'][ticket_type]

    r = Ticket.book_temp(user_id, ticket_type, price, tickets_max, seat_num)

    if r[0]:
        ticket = Ticket.query.filter(Ticket.owner_id == user_id) \
            .filter(or_(Ticket.paid, Ticket.reserved_until >= datetime.now())) \
            .one()
        return jsonify({'ticket': ticket.as_pub_dict()}), 201

    # Conflict while booking ticket
    return jsonify({'error': str(r[1])}), 409
开发者ID:MrPh1l,项目名称:lanmomo-website,代码行数:31,代码来源:app.py


示例13: newticket

def newticket():
    user = g.user
    form = TicketForm()
    if form.validate_on_submit():
        import datetime
        t = Ticket()
        form.populate_obj(t)
        t.timestamp = datetime.datetime.utcnow()
        t.created = datetime.datetime.utcnow()
        t.user_id = user.id
        db.session.add(t);
        db.session.commit()

        flash('New ticket submitted: ' + form.subject.data)
        return redirect('/dashboard')
    return render_template('newticket.html', form=form, user=user)
开发者ID:binaryatrocity,项目名称:packetcrypt,代码行数:16,代码来源:views.py


示例14: testChangeWasSelled

    def testChangeWasSelled(self):
        """
        TODO
        """
        ticket = Ticket(night=self.night, sector=self.sector, row=1,
                        sit=3, public_type=self.pt)
        ticket.save()

        self.assertEquals(False, ticket.was_selled)

        self.sell = Sell(sell_point=self.sell_point)
        self.sell.save()

        ticket_sell = TicketSell(sell=self.sell, ticket=ticket)
        ticket_sell.save()

        self.assertEquals(True, ticket.was_selled)
开发者ID:ariel17,项目名称:bandfestival,代码行数:17,代码来源:tests.py


示例15: testUniqueTicket

 def testUniqueTicket(self):
     """
     TODO
     """
     with self.assertRaises(IntegrityError):
         self.ticket = Ticket(night=self.night, sector=self.sector, row=1,
                              sit=1, public_type=self.pt)
         self.ticket.save()
开发者ID:ariel17,项目名称:bandfestival,代码行数:8,代码来源:tests.py


示例16: test_model

    def test_model(self):
        """Test Services models"""
        status = TicketStatus(name='TestStatus')
        status.save()
        self.assertNotEquals(status.id, None)

        queue = TicketQueue(name='TestQueue', default_ticket_status=status)
        queue.save()
        self.assertNotEquals(status.id, None)

        ticket = Ticket(name='TestTicket', status=status, queue=queue)
        ticket.save()
        self.assertNotEquals(ticket.id, None)

        ticket.delete()
        queue.delete()
        status.delete()
开发者ID:tovmeod,项目名称:anaf,代码行数:17,代码来源:tests.py


示例17: on_pay_clicked

 def on_pay_clicked(self,widget,data=None):
     id = self.serial_number.get_text()
     ticket = Ticket.get(id=id)
     ticket.paid = True
     ticket.paidDate = datetime.now()
     ticket.save()
     self.serial_number.set_text("")
     self.validity_label.set_text("")
     self.pay.set_sensitive(False)
开发者ID:Okiria,项目名称:betting,代码行数:9,代码来源:bet_interface.py


示例18: verify

def verify(ticket_id):
    try:
        ticket = Ticket.get(id = ticket_id)
        if ticket.has_won():
            return ticket
        else:
            return None
    except Ticket.DoesNotExist:
        return None
开发者ID:Okiria,项目名称:betting,代码行数:9,代码来源:api.py


示例19: test_new_ticket

 def test_new_ticket(self):
     ticket = Ticket()
     ticket.source = 'contact_form'
     ticket.status = 'new'
     ticket.sender = User.objects.get(username='test_user')
     ticket.queue = Queue.objects.get(name=QUEUE_SUPPORT_REQUESTS)
     ticket.save()
     self.assertEqual(ticket.assignee, None)
开发者ID:takuya1981,项目名称:freesound,代码行数:8,代码来源:tests.py


示例20: test_new_ticket_linked_content

 def test_new_ticket_linked_content(self):
     ticket = Ticket()
     ticket.source = 'new_sound'
     ticket.status = 'new'
     ticket.sender = User.objects.get(username='test_user')
     ticket.assignee = User.objects.get(username='test_moderator')
     ticket.queue = Queue.objects.get(name=QUEUE_SOUND_MODERATION)
     ticket.save()
     lc = LinkedContent()
     # just to test, this would be a sound object for example
     lc.content_object = User.objects.get(username='test_admin')
     lc.save() 
     ticket.content = lc
     ticket.content.save()
     self.assertEqual(User.objects.get(username='test_admin').id, 
                      ticket.content.object_id)
开发者ID:takuya1981,项目名称:freesound,代码行数:16,代码来源:tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Todo类代码示例发布时间:2022-05-27
下一篇:
Python models.TestResult类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap