本文整理汇总了Python中helpdesk.models.Ticket.create方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.create方法的具体用法?Python Ticket.create怎么用?Python Ticket.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpdesk.models.Ticket
的用法示例。
在下文中一共展示了Ticket.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_messages
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import create [as 别名]
def handle_messages(self, imbox, project, email=None, assignee=None):
logger.info("--- Started processing emails ---")
unread_messages = imbox.messages(unread=True, folder='INBOX', sent_to=email or project.email)
for uid, message in unread_messages:
try:
subject = getattr(message, 'subject', 'Email ticket')
logger.info("Got message %s: %s" % (uid, subject))
if SETTINGS['ignore_autoreply'] and self._is_autoreply(message):
logger.info(' Message is auto-submitted, skipping')
if SETTINGS['mark_seen']:
imbox.mark_seen(uid)
continue
if Ticket.objects.filter(message_id=uid).exists() or Comment.objects.filter(message_id=uid).exists():
logger.info(' Message already exists, skipping')
if SETTINGS['mark_seen']:
imbox.mark_seen(uid)
continue
try:
body = message.body['html'][0]
except IndexError:
try:
body = message.body['plain'][0]
except IndexError:
body = ''
initial = self._get_initial_issue(message)
if initial is None:
ticket = Ticket.create(
title=subject[:255],
body=body,
customer=message.sent_from[0]['email'],
message_id=uid,
assignee=assignee or project.default_assignee,
project=project
)
logger.info(' Created new ticket')
self._create_attachments(message.attachments, ticket)
else:
comment = Comment.objects.create(
body=body,
author=None,
message_id=uid,
ticket=initial
)
self._create_attachments(message.attachments, comment)
logger.info(' Added comment to ticket')
if SETTINGS['mark_seen']:
imbox.mark_seen(uid)
except Exception:
logger.exception(' Error while retrieving email %s' % uid)
logger.info("--- Finished processing emails ---")
示例2: form_valid
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import create [as 别名]
def form_valid(self, form):
if not self.attachment_formset.is_valid():
return self.render_to_response(self.get_context_data())
data = form.cleaned_data
comment = data.pop('comment')
ticket = Ticket.create(body='This ticket was created by [user:%d]' % self.request.user.pk,
message_id='ticket-%d' % time.mktime(now().timetuple()),
author=self.request.user,
**data)
reply = Comment.objects.create(ticket=ticket, body=comment, author=self.request.user)
self.attachment_formset.instance = reply
self.attachment_formset.save()
new_answer.send(sender=Comment, ticket=ticket, answer=reply)
return HttpResponseRedirect(reverse('helpdesk_home'))