mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-23 08:23:54 +01:00
Merge pull request #351 from flinz/django-1.8
Django 1.8 compatibility including updated testrunners
This commit is contained in:
commit
0d995e0235
@ -85,7 +85,14 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
|
|||||||
|
|
||||||
footer_file = os.path.join('helpdesk', locale, 'email_text_footer.txt')
|
footer_file = os.path.join('helpdesk', locale, 'email_text_footer.txt')
|
||||||
|
|
||||||
text_part = loader.get_template_from_string(
|
# 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
|
||||||
|
template_func = engines['django'].from_string
|
||||||
|
except ImportError: # occurs in django < 1.8
|
||||||
|
template_func = loader.get_template_from_string
|
||||||
|
|
||||||
|
text_part = template_func(
|
||||||
"%s{%% include '%s' %%}" % (t.plain_text, footer_file)
|
"%s{%% include '%s' %%}" % (t.plain_text, footer_file)
|
||||||
).render(context)
|
).render(context)
|
||||||
|
|
||||||
@ -100,11 +107,13 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
|
|||||||
html_txt = html_txt.replace('\r\n', '<br>')
|
html_txt = html_txt.replace('\r\n', '<br>')
|
||||||
context['comment'] = mark_safe(html_txt)
|
context['comment'] = mark_safe(html_txt)
|
||||||
|
|
||||||
html_part = loader.get_template_from_string(
|
# get_template_from_string was removed in Django 1.8 http://django.readthedocs.org/en/1.8.x/ref/templates/upgrading.html
|
||||||
|
html_part = template_func(
|
||||||
"{%% extends '%s' %%}{%% block title %%}%s{%% endblock %%}{%% block content %%}%s{%% endblock %%}" % (email_html_base_file, t.heading, t.html)
|
"{%% extends '%s' %%}{%% block title %%}%s{%% endblock %%}{%% block content %%}%s{%% endblock %%}" % (email_html_base_file, t.heading, t.html)
|
||||||
).render(context)
|
).render(context)
|
||||||
|
|
||||||
subject_part = loader.get_template_from_string(
|
# get_template_from_string was removed in Django 1.8 http://django.readthedocs.org/en/1.8.x/ref/templates/upgrading.html
|
||||||
|
subject_part = template_func(
|
||||||
HELPDESK_EMAIL_SUBJECT_TEMPLATE % {
|
HELPDESK_EMAIL_SUBJECT_TEMPLATE % {
|
||||||
"subject": t.subject,
|
"subject": t.subject,
|
||||||
}).render(context)
|
}).render(context)
|
||||||
|
29
helpdesk/migrations/0005_queues_no_null.py
Normal file
29
helpdesk/migrations/0005_queues_no_null.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('helpdesk', '0004_add_per_queue_staff_membership'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='escalationexclusion',
|
||||||
|
name='queues',
|
||||||
|
field=models.ManyToManyField(help_text='Leave blank for this exclusion to be applied to all queues, or select those queues you wish to exclude with this entry.', to='helpdesk.Queue', blank=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ignoreemail',
|
||||||
|
name='queues',
|
||||||
|
field=models.ManyToManyField(help_text='Leave blank for this e-mail to be ignored on all queues, or select those queues you wish to ignore this e-mail for.', to='helpdesk.Queue', blank=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='presetreply',
|
||||||
|
name='queues',
|
||||||
|
field=models.ManyToManyField(help_text='Leave blank to allow this reply to be used for all queues, or select those queues you wish to limit this reply to.', to='helpdesk.Queue', blank=True),
|
||||||
|
),
|
||||||
|
]
|
29
helpdesk/migrations/0006_email_maxlength.py
Normal file
29
helpdesk/migrations/0006_email_maxlength.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('helpdesk', '0005_queues_no_null'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='queue',
|
||||||
|
name='email_address',
|
||||||
|
field=models.EmailField(help_text='All outgoing e-mails for this queue will use this e-mail address. If you use IMAP or POP3, this should be the e-mail address for that mailbox.', max_length=254, null=True, verbose_name='E-Mail Address', blank=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ticket',
|
||||||
|
name='submitter_email',
|
||||||
|
field=models.EmailField(help_text='The submitter will receive an email for all public follow-ups left for this task.', max_length=254, null=True, verbose_name='Submitter E-Mail', blank=True),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ticketcc',
|
||||||
|
name='email',
|
||||||
|
field=models.EmailField(help_text='For non-user followers, enter their e-mail address', max_length=254, null=True, verbose_name='E-Mail Address', blank=True),
|
||||||
|
),
|
||||||
|
]
|
@ -1,4 +1,9 @@
|
|||||||
from helpdesk.tests.ticket_submission import *
|
# import all test_*.py files in directory.
|
||||||
from helpdesk.tests.public_actions import *
|
# neccessary for automatic discovery in django <= 1.5
|
||||||
from helpdesk.tests.navigation import *
|
# http://stackoverflow.com/a/15780326/1382740
|
||||||
from helpdesk.tests.per_queue_staff_membership import *
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
def suite():
|
||||||
|
return unittest.TestLoader().discover("helpdesk.tests", pattern="test_*.py")
|
||||||
|
@ -26,8 +26,15 @@ def reload_urlconf(urlconf=None):
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
urlconf = settings.ROOT_URLCONF
|
urlconf = settings.ROOT_URLCONF
|
||||||
if urlconf in sys.modules:
|
|
||||||
from django.core.urlresolvers import clear_url_caches
|
|
||||||
|
|
||||||
|
if HELPDESK_URLCONF in sys.modules:
|
||||||
|
reload(sys.modules[HELPDESK_URLCONF])
|
||||||
|
|
||||||
|
if urlconf in sys.modules:
|
||||||
reload(sys.modules[urlconf])
|
reload(sys.modules[urlconf])
|
||||||
|
|
||||||
|
from django.core.urlresolvers import clear_url_caches
|
||||||
clear_url_caches()
|
clear_url_caches()
|
||||||
|
|
||||||
|
|
||||||
|
HELPDESK_URLCONF = 'helpdesk.urls'
|
||||||
|
@ -367,7 +367,16 @@ def update_ticket(request, ticket_id, public=False):
|
|||||||
# if comment contains some django code, like "why does {% if bla %} crash",
|
# if comment contains some django code, like "why does {% if bla %} crash",
|
||||||
# then the following line will give us a crash, since django expects {% if %}
|
# then the following line will give us a crash, since django expects {% if %}
|
||||||
# to be closed with an {% endif %} tag.
|
# to be closed with an {% endif %} tag.
|
||||||
comment = loader.get_template_from_string(comment).render(Context(context))
|
|
||||||
|
|
||||||
|
# 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
|
||||||
|
template_func = engines['django'].from_string
|
||||||
|
except ImportError: # occurs in django < 1.8
|
||||||
|
template_func = loader.get_template_from_string
|
||||||
|
|
||||||
|
comment = template_func(comment).render(Context(context))
|
||||||
|
|
||||||
if owner is -1 and ticket.assigned_to:
|
if owner is -1 and ticket.assigned_to:
|
||||||
owner = ticket.assigned_to.id
|
owner = ticket.assigned_to.id
|
||||||
|
15
quicktest.py
15
quicktest.py
@ -93,11 +93,22 @@ class QuickDjangoTest(object):
|
|||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# compatibility with django 1.8 downwards
|
||||||
|
# see: http://stackoverflow.com/questions/3841725/how-to-launch-tests-for-django-reusable-app
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Django >= 1.6
|
||||||
|
from django.test.runner import DiscoverRunner
|
||||||
|
test_runner = DiscoverRunner(verbosity=1)
|
||||||
|
except ImportError:
|
||||||
|
# Django <= 1.5
|
||||||
|
from django.test.simple import DjangoTestSuiteRunner
|
||||||
|
test_runner = DjangoTestSuiteRunner(verbosity=1)
|
||||||
|
|
||||||
if django.VERSION >= (1, 7):
|
if django.VERSION >= (1, 7):
|
||||||
django.setup()
|
django.setup()
|
||||||
|
|
||||||
from django.test.simple import DjangoTestSuiteRunner
|
failures = test_runner.run_tests(self.apps)
|
||||||
failures = DjangoTestSuiteRunner().run_tests(self.apps, verbosity=1)
|
|
||||||
if failures:
|
if failures:
|
||||||
sys.exit(failures)
|
sys.exit(failures)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user