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"`` **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 Options shown on public pages
----------------------------- -----------------------------

View File

@ -56,7 +56,8 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
from django.template import loader, Context from django.template import loader, Context
from helpdesk.models import EmailTemplate 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 import os
# RemovedInDjango110Warning: render() must be called with a dict, not a Context. # 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'): if hasattr(context['queue'], 'locale'):
locale = getattr(context['queue'], 'locale', '') locale = getattr(context['queue'], 'locale', '')
else: else:
locale = context['queue'].get('locale', 'en') locale = context['queue'].get('locale', HELPDESK_EMAIL_FALLBACK_LOCALE)
if not locale: if not locale:
locale = 'en' locale = HELPDESK_EMAIL_FALLBACK_LOCALE
t = None t = None
try: try:

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. # 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") 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 ''' ''' options for staff.create_ticket view '''
# hide the 'assigned to' / 'Case owner' field from the 'create_ticket' view? # hide the 'assigned to' / 'Case owner' field from the 'create_ticket' view?