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


Python Ticket.save方法代码示例

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


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

示例1: test_new_ticket

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
 def test_new_ticket(self):
     ticket = Ticket()
     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:,项目名称:,代码行数:9,代码来源:

示例2: update_token

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
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:,项目名称:,代码行数:31,代码来源:

示例3: testReSellCancelledTicket

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
    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,代码行数:30,代码来源:tests.py

示例4: update_jsapi

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
def update_jsapi():
  print 'update jsapi'
  params = {
    'access_token': get_ticket(1).content,
    'type': 'jsapi',
  }
  host = 'api.weixin.qq.com'
  path = '/cgi-bin/ticket/getticket'
  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('ticket')
  starttime = timezone.now()
  expires_in = timedelta(seconds=int(res[1].get('expires_in')))
  endtime = starttime + expires_in
  token_record = Ticket.objects.filter(ticket_type=2).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.ticket_type = 2
  token_record.save()
  return token_record
开发者ID:,项目名称:,代码行数:31,代码来源:

示例5: new_contact_ticket

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
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,代码行数:27,代码来源:views.py

示例6: get

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
    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,代码行数:31,代码来源:views.py

示例7: getTicketForUser

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
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,代码行数:10,代码来源:auth.py

示例8: setUp

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
    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()

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

        ticket2 = Ticket(night=self.night, sector=self.sector, row=1,
                        sit=2, public_type=self.pt)
        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=ticket1)
        ticket_sell.save()

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

示例9: create_node

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
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,代码行数:11,代码来源:views.py

示例10: make_some_db

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
    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,代码行数:58,代码来源:dataAdapter.py

示例11: new_ticket

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
def new_ticket(request, *arg):
    """
    For generating new tickets
    """
    if request.method == 'POST':
        form = TicketForm(request.POST)
        if form.is_valid():
            t = Ticket()
            t.ticket_type = form.cleaned_data['ticket_type']
            t.project = form.cleaned_data['project']
            t.component = form.cleaned_data['component']
            t.summary = form.cleaned_data['summary']
            t.description = form.cleaned_data['description']
            t.created_by = request.user
            t.updated_by = request.user
            # workflow related stuff
            ticket_type = t.ticket_type
            wm = WorkflowManager()
            wm.workflow = ticket_type.workflow
            wm.created_by = request.user
            wm.save()
            r = Role.objects.get(id=settings.ROLE_SUBMITTER)
            p = Participant()
            p.user = request.user
            p.role = r
            p.workflowmanager=wm
            p.save()
            t.workflow_manager=wm
            t.save()
            wm.start(p)
            # Generates a confirmation email to send to the new user
            current_site = Site.objects.get_current() 
            site_name = current_site.name
            domain = current_site.domain
            tplt = loader.get_template(settings.NEW_TICKET_EMAIL_TEMPLATE)
            c = {
                'email': request.user.email,
                'domain': domain,
                'site_name': site_name,
                'user': request.user,
                'protocol': settings.REGISTRATION_USE_HTTPS and 'https' or 'http',
                'ticket': t,
            }
            send_mail(_("Confirmation of new ticket on IssueTracker"),
                tplt.render(Context(c)), None, [request.user.email])
            
            request.user.message_set.create(message=_("The ticket has been"\
                    " successfully created."))
            return HttpResponseRedirect('/ticket/%d'%t.id)
    else:
        form = TicketForm()
    c = RequestContext(request, {'form': form})
    return render_to_response('new.html', c) 
开发者ID:ntoll,项目名称:IssueTracker,代码行数:55,代码来源:views.py

示例12: test_new_ticket_linked_sound

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
 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:,项目名称:,代码行数:16,代码来源:

示例13: test_new_ticket_linked_content

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
 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,代码行数:18,代码来源:tests.py

示例14: test_model

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
    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,代码行数:19,代码来源:tests.py

示例15: testChangeWasSelled

# 需要导入模块: from models import Ticket [as 别名]
# 或者: from models.Ticket import save [as 别名]
    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,代码行数:19,代码来源:tests.py


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