forked from extern/django-helpdesk
Merge pull request #540 from msaelices/master
Fix `AttributeError` while staff user does a mass update in some tickets using the `Close (Send E-mail)` action
This commit is contained in:
commit
c3eeb15b61
@ -191,6 +191,38 @@ def apply_query(queryset, params):
|
|||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
|
def ticket_template_context(ticket):
|
||||||
|
context = {}
|
||||||
|
|
||||||
|
for field in ('title', 'created', 'modified', 'submitter_email',
|
||||||
|
'status', 'get_status_display', 'on_hold', 'description',
|
||||||
|
'resolution', 'priority', 'get_priority_display',
|
||||||
|
'last_escalation', 'ticket', 'ticket_for_url',
|
||||||
|
'get_status', 'ticket_url', 'staff_url', '_get_assigned_to'
|
||||||
|
):
|
||||||
|
attr = getattr(ticket, field, None)
|
||||||
|
if callable(attr):
|
||||||
|
context[field] = '%s' % attr()
|
||||||
|
else:
|
||||||
|
context[field] = attr
|
||||||
|
context['assigned_to'] = context['_get_assigned_to']
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
def queue_template_context(queue):
|
||||||
|
context = {}
|
||||||
|
|
||||||
|
for field in ('title', 'slug', 'email_address', 'from_address', 'locale'):
|
||||||
|
attr = getattr(queue, field, None)
|
||||||
|
if callable(attr):
|
||||||
|
context[field] = attr()
|
||||||
|
else:
|
||||||
|
context[field] = attr
|
||||||
|
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
def safe_template_context(ticket):
|
def safe_template_context(ticket):
|
||||||
"""
|
"""
|
||||||
Return a dictionary that can be used as a template context to render
|
Return a dictionary that can be used as a template context to render
|
||||||
@ -207,32 +239,10 @@ def safe_template_context(ticket):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'queue': {},
|
'queue': queue_template_context(ticket.queue),
|
||||||
'ticket': {}
|
'ticket': ticket_template_context(ticket),
|
||||||
}
|
}
|
||||||
queue = ticket.queue
|
|
||||||
|
|
||||||
for field in ('title', 'slug', 'email_address', 'from_address', 'locale'):
|
|
||||||
attr = getattr(queue, field, None)
|
|
||||||
if callable(attr):
|
|
||||||
context['queue'][field] = attr()
|
|
||||||
else:
|
|
||||||
context['queue'][field] = attr
|
|
||||||
|
|
||||||
for field in ('title', 'created', 'modified', 'submitter_email',
|
|
||||||
'status', 'get_status_display', 'on_hold', 'description',
|
|
||||||
'resolution', 'priority', 'get_priority_display',
|
|
||||||
'last_escalation', 'ticket', 'ticket_for_url',
|
|
||||||
'get_status', 'ticket_url', 'staff_url', '_get_assigned_to'
|
|
||||||
):
|
|
||||||
attr = getattr(ticket, field, None)
|
|
||||||
if callable(attr):
|
|
||||||
context['ticket'][field] = '%s' % attr()
|
|
||||||
else:
|
|
||||||
context['ticket'][field] = attr
|
|
||||||
|
|
||||||
context['ticket']['queue'] = context['queue']
|
context['ticket']['queue'] = context['queue']
|
||||||
context['ticket']['assigned_to'] = context['ticket']['_get_assigned_to']
|
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ from helpdesk.forms import (
|
|||||||
)
|
)
|
||||||
from helpdesk.lib import (
|
from helpdesk.lib import (
|
||||||
send_templated_mail, query_to_dict, apply_query, safe_template_context,
|
send_templated_mail, query_to_dict, apply_query, safe_template_context,
|
||||||
process_attachments,
|
process_attachments, queue_template_context,
|
||||||
)
|
)
|
||||||
from helpdesk.models import (
|
from helpdesk.models import (
|
||||||
Ticket, Queue, FollowUp, TicketChange, PreSetReply, Attachment, SavedSearch,
|
Ticket, Queue, FollowUp, TicketChange, PreSetReply, Attachment, SavedSearch,
|
||||||
@ -696,7 +696,7 @@ def mass_update(request):
|
|||||||
# Send email to Submitter, Owner, Queue CC
|
# Send email to Submitter, Owner, Queue CC
|
||||||
context = safe_template_context(t)
|
context = safe_template_context(t)
|
||||||
context.update(resolution=t.resolution,
|
context.update(resolution=t.resolution,
|
||||||
queue=t.queue)
|
queue=queue_template_context(t.queue))
|
||||||
|
|
||||||
messages_sent_to = []
|
messages_sent_to = []
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -6,7 +6,7 @@ from distutils.util import convert_path
|
|||||||
from fnmatch import fnmatchcase
|
from fnmatch import fnmatchcase
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
version = '0.2.0'
|
version = '0.2.0.1'
|
||||||
|
|
||||||
# Provided as an attribute, so you can append to these instead
|
# Provided as an attribute, so you can append to these instead
|
||||||
# of replicating them:
|
# of replicating them:
|
||||||
|
Loading…
Reference in New Issue
Block a user