Merge pull request #426 from meomap/email-fallback-locale

remove hardcode default locale
This commit is contained in:
Jonathan Barratt 2016-10-15 22:38:54 -04:00 committed by GitHub
commit 0d8e81d7f0
3 changed files with 14 additions and 6 deletions

View File

@ -68,6 +68,10 @@ These changes are visible throughout django-helpdesk
**Default:** ``HELPDESK_EMAIL_SUBJECT_TEMPLATE = "{{ ticket.ticket }} {{ ticket.title|safe }} %(subject)s"``
- **HELPDESK_EMAIL_FALLBACK_LOCALE** Fallback locale for templated emails when queue locale not found
**Default:** ``HELPDESK_EMAIL_FALLBACK_LOCALE= "en"``
Options shown on public pages
-----------------------------

View File

@ -46,7 +46,7 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
fail_silently is passed to Django's mail routine. Set to 'True' to ignore
any errors at send time.
files can be a list of tuple. Each tuple should be a filename to attach,
files can be a list of tuple. Each tuple should be a filename to attach,
along with the File objects to be read. files can be blank.
"""
@ -56,7 +56,8 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
from django.template import loader, Context
from helpdesk.models import EmailTemplate
from helpdesk.settings import HELPDESK_EMAIL_SUBJECT_TEMPLATE
from helpdesk.settings import HELPDESK_EMAIL_SUBJECT_TEMPLATE, \
HELPDESK_EMAIL_FALLBACK_LOCALE
import os
# RemovedInDjango110Warning: render() must be called with a dict, not a Context.
@ -68,9 +69,9 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
if hasattr(context['queue'], 'locale'):
locale = getattr(context['queue'], 'locale', '')
else:
locale = context['queue'].get('locale', 'en')
locale = context['queue'].get('locale', HELPDESK_EMAIL_FALLBACK_LOCALE)
if not locale:
locale = 'en'
locale = HELPDESK_EMAIL_FALLBACK_LOCALE
t = None
try:
@ -90,7 +91,7 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
sender = settings.DEFAULT_FROM_EMAIL
footer_file = os.path.join('helpdesk', locale, 'email_text_footer.txt')
# get_template_from_string was removed in Django 1.8 http://django.readthedocs.org/en/1.8.x/ref/templates/upgrading.html
try:
from django.template import engines
@ -178,7 +179,7 @@ def apply_query(queryset, params):
params is a dictionary that contains the following:
filtering: A dict of Django ORM filters, eg:
{'user__id__in': [1, 3, 103], 'title__contains': 'foo'}
search_string: A freetext search string
sorting: The name of the column to sort by

View File

@ -86,6 +86,9 @@ HELPDESK_STAFF_ONLY_TICKET_CC = getattr(settings, 'HELPDESK_STAFF_ONLY_TICKET_CC
# allow the subject to have a configurable template.
HELPDESK_EMAIL_SUBJECT_TEMPLATE = getattr(settings, 'HELPDESK_EMAIL_SUBJECT_TEMPLATE', "{{ ticket.ticket }} {{ ticket.title|safe }} %(subject)s")
# default fallback locale when queue locale not found
HELPDESK_EMAIL_FALLBACK_LOCALE = getattr(settings, 'HELPDESK_EMAIL_FALLBACK_LOCALE', 'en')
''' options for staff.create_ticket view '''
# hide the 'assigned to' / 'Case owner' field from the 'create_ticket' view?