本文整理汇总了Python中helpdesk.models.Ticket.submitter_email方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.submitter_email方法的具体用法?Python Ticket.submitter_email怎么用?Python Ticket.submitter_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpdesk.models.Ticket
的用法示例。
在下文中一共展示了Ticket.submitter_email方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import submitter_email [as 别名]
def save(self, user, queue_id):
"""
Writes and returns a Ticket() object
"""
q = Queue.objects.get(id=queue_id)
t = Ticket(title=self.cleaned_data['title'],
created=timezone.now(),
status=Ticket.OPEN_STATUS,
queue=q,
description=self.cleaned_data['body']
)
#t.assigned_to_id = 1
t.submitter_email = getattr(user, 'email', '')
t.save()
for field, value in self.cleaned_data.items():
if field.startswith('custom_'):
field_name = field.replace('custom_', '')
customfield = CustomField.objects.get(name=field_name)
cfv = TicketCustomFieldValue(ticket=t,
field=customfield,
value=value)
cfv.save()
f = FollowUp(ticket = t,
title = _('Ticket Opened'),
date = timezone.now(),
public = True,
comment = self.cleaned_data['body'],
user = user if user.is_authenticated() else None,
)
f.title = _('Ticket Opened & Assigned to %(name)s') % {
'name': t.get_assigned_to
}
f.save()
files = []
if self.cleaned_data['attachment']:
import mimetypes
file = self.cleaned_data['attachment']
filename = file.name.replace(' ', '_')
a = Attachment(
followup=f,
filename=filename,
mime_type=mimetypes.guess_type(filename)[0] or 'application/octet-stream',
size=file.size,
)
a.file.save(file.name, file, save=False)
a.save()
if file.size < getattr(settings, 'MAX_EMAIL_ATTACHMENT_SIZE', 2012000):
# Only files smaller than 512kb (or as defined in
# settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
try:
files.append(a.file.path)
except NotImplementedError:
pass
context = safe_template_context(t)
context['comment'] = f.comment
messages_sent_to = []
if t.submitter_email:
send_templated_mail(
'newticket_submitter',
context,
recipients=t.submitter_email,
sender=q.from_address,
fail_silently=True,
files=files,
)
messages_sent_to.append(t.submitter_email)
if t.assigned_to and t.assigned_to != user and t.assigned_to.usersettings.settings.get('email_on_ticket_assign', False) and t.assigned_to.email and t.assigned_to.email not in messages_sent_to:
send_templated_mail(
'assigned_owner',
context,
recipients=t.assigned_to.email,
sender=q.from_address,
fail_silently=True,
files=files,
)
messages_sent_to.append(t.assigned_to.email)
if q.new_ticket_cc and q.new_ticket_cc not in messages_sent_to:
send_templated_mail(
'newticket_cc',
context,
recipients=q.new_ticket_cc,
sender=q.from_address,
fail_silently=True,
files=files,
)
messages_sent_to.append(q.new_ticket_cc)
#.........这里部分代码省略.........