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