本文整理汇总了Python中helpdesk.models.Ticket.save方法的典型用法代码示例。如果您正苦于以下问题:Python Ticket.save方法的具体用法?Python Ticket.save怎么用?Python Ticket.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpdesk.models.Ticket
的用法示例。
在下文中一共展示了Ticket.save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def setUp(self):
q = Queue(title='Q1', slug='q1')
q.save()
t = Ticket(title='Test Ticket', submitter_email='[email protected]')
t.queue = q
t.save()
self.ticket = t
示例2: save
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def save(self, user):
"""
Writes and returns a Ticket() object
"""
q = Queue.objects.get(id=int(self.cleaned_data['queue']))
t = Ticket( title = self.cleaned_data['title'],
submitter_email = self.cleaned_data['submitter_email'],
created = timezone.now(),
status = Ticket.OPEN_STATUS,
queue = q,
description = self.cleaned_data['body'],
error_msg = self.cleaned_data['error_msg'],
priority = self.cleaned_data['priority'],
type = self.cleaned_data['type'],
due_date = self.cleaned_data['due_date'],
)
t.assigned_to = None
if self.cleaned_data['assigned_to']:
try:
u = User.objects.get(id=self.cleaned_data['assigned_to'])
t.assigned_to = u
except User.DoesNotExist:
pass
t.save()
for field, value in self.cleaned_data.items():
if field.startswith('custom_'):
field_name = field.replace('custom_', '', 1)
customfield = CustomField.objects.get(name=field_name)
cfv = TicketCustomFieldValue(ticket=t,
field=customfield,
value=value)
cfv.save()
ticket = t
user = None
try:
user = t.assigned_to
except Exception, e:
pass
示例3: save
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def save(self):
"""
Writes and returns a Ticket() object
"""
q = Queue.objects.get(id=int(self.cleaned_data['queue']))
t = Ticket(
title = self.cleaned_data['title'],
submitter_email = self.cleaned_data['submitter_email'],
created = datetime.now(),
status = Ticket.OPEN_STATUS,
queue = q,
description = self.cleaned_data['body'],
priority = self.cleaned_data['priority'],
due_date = self.cleaned_data['due_date'],
)
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 Via Web'),
date = datetime.now(),
public = True,
comment = self.cleaned_data['body'],
)
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', 512000):
# Only files smaller than 512kb (or as defined in
# settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
files.append(a.file.path)
context = safe_template_context(t)
messages_sent_to = []
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 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)
if q.updated_ticket_cc and q.updated_ticket_cc != q.new_ticket_cc and q.updated_ticket_cc not in messages_sent_to:
send_templated_mail(
'newticket_cc',
context,
recipients=q.updated_ticket_cc,
sender=q.from_address,
fail_silently=True,
files=files,
)
return t
示例4: save
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def save(self, user):
"""
Writes and returns a Ticket() object
"""
q = Queue.objects.get(id=int(self.cleaned_data['queue']))
t = Ticket( title = self.cleaned_data['title'],
submitter_email = self.cleaned_data['submitter_email'],
created = timezone.now(),
status = Ticket.OPEN_STATUS,
queue = q,
description = self.cleaned_data['body'],
priority = self.cleaned_data['priority'],
due_date = self.cleaned_data['due_date'],
)
if HAS_TAG_SUPPORT:
t.tags = self.cleaned_data['tags']
if self.cleaned_data['assigned_to']:
try:
u = User.objects.get(id=self.cleaned_data['assigned_to'])
t.assigned_to = u
except User.DoesNotExist:
t.assigned_to = None
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 self.cleaned_data['assigned_to']:
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', 512000):
# Only files smaller than 512kb (or as defined in
# settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
files.append(a.file.path)
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',
#.........这里部分代码省略.........
示例5: save
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def save(self, user):
"""
Writes and returns a Ticket() object
"""
q = Queue.objects.get(id=int(self.cleaned_data["queue"]))
t = Ticket(
title=self.cleaned_data["title"],
submitter_email=self.cleaned_data["submitter_email"],
created=datetime.now(),
status=Ticket.OPEN_STATUS,
queue=q,
description=self.cleaned_data["body"],
priority=self.cleaned_data["priority"],
due_date=self.cleaned_data["due_date"],
)
if HAS_TAG_SUPPORT:
t.tags = self.cleaned_data["tags"]
if self.cleaned_data["assigned_to"]:
try:
u = User.objects.get(id=self.cleaned_data["assigned_to"])
t.assigned_to = u
except User.DoesNotExist:
t.assigned_to = None
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=datetime.now(),
public=True,
comment=self.cleaned_data["body"],
user=user,
)
if self.cleaned_data["assigned_to"]:
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", 512000):
# Only files smaller than 512kb (or as defined in
# settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
files.append(a.file.path)
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 getattr(t.assigned_to.usersettings.settings, "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,
)
#.........这里部分代码省略.........
示例6: save
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def save(self, user):
"""
Writes and returns a Ticket() object
"""
q = self.cleaned_data['queue']
t = Ticket( title = self.cleaned_data['title'],
submitter_email = self.cleaned_data['submitter_email'],
account = self.cleaned_data['account'],
created = datetime.now(),
status = Ticket.OPEN_STATUS,
queue = q,
description = self.cleaned_data['body'],
priority = self.cleaned_data['priority'],
owner = self.cleaned_data['owner']
)
if HAS_TAG_SUPPORT:
t.tags = self.cleaned_data['tags']
if self.cleaned_data['assigned_to']:
try:
t.assigned_to = self.cleaned_data['assigned_to']
except User.DoesNotExist:
t.assigned_to = None
t.save()
f = FollowUp( ticket = t,
title = _('Ticket Opened'),
date = datetime.now(),
public = False,
comment = self.cleaned_data['body'],
systemuser = user.account,
)
if self.cleaned_data['assigned_to']:
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', 512000):
# Only files smaller than 512kb (or as defined in
# settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
files.append(a.file.path)
context = {
'ticket': t,
'queue': q,
'comment': f.comment,
}
messages_sent_to = []
if t.submitter_email:
send_templated_mail(
'newticket_owner',
context,
recipients=t.submitter_email,
sender=q.from_address,
fail_silently=True,
files=files,
)
messages_sent_to.append(t.submitter_email)
#FIX USERSETTINGS
#=======================================================================
# if t.assigned_to and t.assigned_to != user and getattr(t.assigned_to.usersettings.settings, 'email_on_ticket_assign', False) and t.assigned_to.email and t.assigned_to.email not in messages_sent_to:
# send_templated_mail(
# 'assigned_to',
# 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,
#.........这里部分代码省略.........
示例7: ticket_from_message
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
#.........这里部分代码省略.........
'type': 'text/html',
})
now = datetime.now()
if ticket:
try:
t = Ticket.objects.get(id=ticket)
new = False
except Ticket.DoesNotExist:
ticket = None
priority = 3
smtp_priority = message.get('priority', '')
smtp_importance = message.get('importance', '')
high_priority_types = ('high', 'important', '1', 'urgent')
if smtp_priority in high_priority_types or smtp_importance in high_priority_types:
priority = 2
update = ''
if ticket == None:
t = Ticket(
title=subject,
queue=queue,
submitter_name=sender_name,
submitter_email=sender_email,
created=now,
description=body,
priority=priority,
)
t.save()
new = True
elif t.status == Ticket.CLOSED_STATUS:
t.status = Ticket.REOPENED_STATUS
t.save()
f = FollowUp(
ticket = t,
title = _('E-Mail Received from %(sender_email)s' % {'sender_email': sender_email}),
date = datetime.now(),
public = True,
comment = body,
)
if t.status == Ticket.REOPENED_STATUS:
f.new_status = Ticket.REOPENED_STATUS
f.title = _('Ticket Re-Opened by E-Mail Received from %(sender_email)s' % {'sender_email': sender_email})
f.save()
if not quiet:
print (" [%s-%s] %s%s" % (t.queue.slug, t.id, t.title, update)).encode('ascii', 'replace')
for file in files:
if file['content']:
filename = file['filename'].encode('ascii', 'replace').replace(' ', '_')
filename = re.sub('[^a-zA-Z0-9._-]+', '', filename)
a = Attachment(
followup=f,
filename=filename,
mime_type=file['type'],
size=len(file['content']),
示例8: save
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def save(self):
"""
Writes and returns a Ticket() object
"""
q = Queue.objects.get(title = 'public')
t = Ticket(
title = self.cleaned_data['title'],
submitter_email = self.cleaned_data['submitter_email'],
created = timezone.now(),
status = Ticket.OPEN_STATUS,
queue = q,
description = self.cleaned_data['body'],
priority = 3,
due_date = None,
)
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 Via Web'),
date = timezone.now(),
public = True,
comment = self.cleaned_data['body'],
)
f.save()
files = []
context = safe_template_context(t)
messages_sent_to = []
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 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)
if q.updated_ticket_cc and q.updated_ticket_cc != q.new_ticket_cc and q.updated_ticket_cc not in messages_sent_to:
send_templated_mail(
'newticket_cc',
context,
recipients=q.updated_ticket_cc,
sender=q.from_address,
fail_silently=True,
files=files,
)
return t
示例9: ticket_from_message
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
#.........这里部分代码省略.........
'type': 'text/html',
})
now = timezone.now()
if ticket:
try:
t = Ticket.objects.get(id=ticket)
new = False
logger.info("Found existing ticket with Tracking ID %s-%s" % (t.queue.slug, t.id))
except Ticket.DoesNotExist:
logger.info("Tracking ID %s-%s not associated with existing ticket. Creating new ticket." % (queue.slug, ticket))
ticket = None
priority = 3
smtp_priority = message.get('priority', '')
smtp_importance = message.get('importance', '')
high_priority_types = ('high', 'important', '1', 'urgent')
if smtp_priority in high_priority_types or smtp_importance in high_priority_types:
priority = 2
if ticket is None:
t = Ticket(
title=subject,
queue=queue,
submitter_email=sender_email,
created=now,
description=body,
priority=priority,
)
t.save()
new = True
logger.debug("Created new ticket %s-%s" % (t.queue.slug, t.id))
elif t.status == Ticket.CLOSED_STATUS:
t.status = Ticket.REOPENED_STATUS
t.save()
f = FollowUp(
ticket=t,
title=_('E-Mail Received from %(sender_email)s' % {'sender_email': sender_email}),
date=timezone.now(),
public=True,
comment=body,
)
if t.status == Ticket.REOPENED_STATUS:
f.new_status = Ticket.REOPENED_STATUS
f.title = _('Ticket Re-Opened by E-Mail Received from %(sender_email)s' % {'sender_email': sender_email})
f.save()
logger.debug("Created new FollowUp for Ticket")
if six.PY2:
logger.info(("[%s-%s] %s" % (t.queue.slug, t.id, t.title,)).encode('ascii', 'replace'))
elif six.PY3:
logger.info("[%s-%s] %s" % (t.queue.slug, t.id, t.title,))
for file in files:
if file['content']:
if six.PY2:
filename = file['filename'].encode('ascii', 'replace').replace(' ', '_')
elif six.PY3:
示例10: save
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def save(self):
"""
Writes and returns a Ticket() object
"""
q = self.cleaned_data["queue"]
t = Ticket(
title=self.cleaned_data["title"],
submitter_email=self.cleaned_data["submitter_email"],
created=timezone.now(),
status=Ticket.OPEN_STATUS,
queue=q,
description=self.cleaned_data["body"],
priority=self.cleaned_data["priority"],
due_date=self.cleaned_data["due_date"],
)
t.save()
for field, value in self.cleaned_data.items():
if field.startswith("custom_"):
field_name = field.replace("custom_", "", 1)
customfield = CustomField.objects.get(name=field_name)
cfv = TicketCustomFieldValue(ticket=t, field=customfield, value=value)
cfv.save()
f = FollowUp(
ticket=t,
title=_("Ticket Opened Via Web"),
date=timezone.now(),
public=True,
comment=self.cleaned_data["body"],
)
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", 512000):
# Only files smaller than 512kb (or as defined in
# settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
files.append([a.filename, a.file])
context = safe_template_context(t)
messages_sent_to = []
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 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)
if (
q.updated_ticket_cc
and q.updated_ticket_cc != q.new_ticket_cc
and q.updated_ticket_cc not in messages_sent_to
):
send_templated_mail(
"newticket_cc",
context,
recipients=q.updated_ticket_cc,
sender=q.from_address,
fail_silently=True,
files=files,
)
return t
示例11: ticket_from_message
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
#.........这里部分代码省略.........
'type': 'text/html',
})
now = datetime.now()
if ticket:
try:
t = Ticket.objects.get(id=ticket)
new = False
except Ticket.DoesNotExist:
logger.debug("Didn't find a ticket with ID %s" % ticket)
ticket = None
priority = 3
smtp_priority = message.get('priority', '')
smtp_importance = message.get('importance', '')
high_priority_types = ('high', 'important', '1', 'urgent')
if smtp_priority in high_priority_types or smtp_importance in high_priority_types:
priority = 2
if ticket == None:
logger.debug("Creating new ticket for email")
t = Ticket(
title=subject,
queue=queue,
submitter_email=sender_email,
created=now,
description=body,
priority=priority,
)
t.save()
new = True
update = ''
elif t.status == Ticket.CLOSED_STATUS:
logger.debug("Reopening ticket")
t.status = Ticket.REOPENED_STATUS
t.save()
f = FollowUp(
ticket = t,
title = _('E-Mail Received from %(sender_email)s' % {'sender_email': sender_email}),
date = datetime.now(),
public = True,
comment = body,
)
if t.status == Ticket.REOPENED_STATUS:
f.new_status = Ticket.REOPENED_STATUS
f.title = _('Ticket Re-Opened by E-Mail Received from %(sender_email)s' % {'sender_email': sender_email})
f.save()
if not quiet:
logger.info(" [%s-%s] %s%s" % (t.queue.slug, t.id, t.title, update)).encode('ascii', 'replace')
for file in files:
if file['content']:
filename = file['filename'].encode('ascii', 'replace').replace(' ', '_')
filename = re.sub('[^a-zA-Z0-9._-]+', '', filename)
a = Attachment(
followup=f,
filename=filename,
示例12: save
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def save(self, owner=None):
"""
Writes and returns a Ticket() object
"""
q = Queue.objects.get(id=int(self.cleaned_data["queue"]))
t = Ticket(
title=self.cleaned_data["title"],
owner=owner,
submitter_email=self.cleaned_data["submitter_email"],
created=datetime.now(),
status=Ticket.OPEN_STATUS,
queue=q,
description=self.cleaned_data["body"],
priority=self.cleaned_data["priority"],
account=owner.account,
)
t.save()
f = FollowUp(
ticket=t,
title=_("Ticket Opened Via Web"),
date=datetime.now(),
public=True,
comment=self.cleaned_data["body"],
account=owner.account,
)
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", 512000):
# Only files smaller than 512kb (or as defined in
# settings.MAX_EMAIL_ATTACHMENT_SIZE) are sent via email.
files.append(a.file.path)
context = {"ticket": t, "queue": q}
messages_sent_to = []
send_templated_mail(
"newticket_owner",
context,
recipients=t.submitter_email,
sender=q.from_address,
fail_silently=True,
files=files,
)
messages_sent_to.append(t.submitter_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)
if (
q.updated_ticket_cc
and q.updated_ticket_cc != q.new_ticket_cc
and q.updated_ticket_cc not in messages_sent_to
):
send_templated_mail(
"newticket_cc",
context,
recipients=q.updated_ticket_cc,
sender=q.from_address,
fail_silently=True,
files=files,
)
return t
示例13: process
# 需要导入模块: from helpdesk.models import Ticket [as 别名]
# 或者: from helpdesk.models.Ticket import save [as 别名]
def process(mail):
"""
All Actionpatterns are
processed and, where they match, actions are created. If this
message is in reply to another mail any outstanding reply action
on that mail is marked as resolved. Finally, if no action has
been created for this email then a reply action is created.
"""
action_created = False
patterns = ActionPattern.objects.filter(active = True)
for pattern in patterns:
create_action = True
if pattern.subject_pattern:
expr = re.compile(pattern.subject_pattern, re.IGNORECASE)
if expr.match(mail.subject):
create_action = True
else:
create_action = False
if create_action and pattern.body_pattern:
expr = re.compile(pattern.body_pattern, re.IGNORECASE)
if expr.match(mail.body):
create_action = True
else:
create_action = False
if create_action and pattern.from_pattern:
expr = re.compile(pattern.from_pattern, re.IGNORECASE)
if expr.match(mail.fromParticipant):
create_action = True
else:
create_action = False
if create_action:
ticket = Ticket(title = pattern.action_title,
description = pattern.action_description,
queue = pattern.action_queue,
created = datetime.now(),
status = Ticket.OPEN_STATUS,
priority = pattern.action_priority)
ticket.save()
mail.action.add(ticket)
action_created = True
if not action_created:
queue = Queue.objects.get(pk=1)
# if this is in reply to another mail we already have, flag other mail as replied to
if mail.backlink is not None:
if Message.objects.filter(messageID = mail.backlink).count() > 0:
repliedTo = Message.objects.filter(messageID = mail.backlink)[0]
repliedTo.record_reply_received(mail)
# if this mail doesn't already have a reply then set an action to check for one
id = mail.messageID
emails = Message.objects.all()
replies = Message.objects.filter(backlink = id).count()
if replies == 0:
description = "Check that the email has received a reply if necessary."
ticket = Ticket(title = "Reply needed for '" + mail.subject + "'",
description = description,
queue = queue,
created = datetime.now(),
status = Ticket.OPEN_STATUS,
priority = 3)
ticket.save()
mail.action.add(ticket)