Skip to content
Snippets Groups Projects
Commit 6b5d5a5a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '231-templates' into 'devel_0.11.x'

Resolve "templates with flying team name containing unicode characters crash"

See merge request NCER-PD/scheduling-system!154
parents 85a9810c 2f1af9d9
No related branches found
No related tags found
1 merge request!154Resolve "templates with flying team name containing unicode characters crash"
Pipeline #
...@@ -185,10 +185,10 @@ class MailTemplate(models.Model): ...@@ -185,10 +185,10 @@ class MailTemplate(models.Model):
"##A_DATE_FULL##": appointment_date_full, "##A_DATE_FULL##": appointment_date_full,
"##A_DATE_SHORT##": appointment_date_short, "##A_DATE_SHORT##": appointment_date_short,
"##A_TIME##": appointment_date_time, "##A_TIME##": appointment_date_time,
"##A_FLYING_TEAM##": str(appointment.flying_team), "##A_FLYING_TEAM##": unicode(appointment.flying_team),
"##A_STATUS##": appointment.get_status_display(), "##A_STATUS##": appointment.get_status_display(),
"##A_LOCATION##": appointment.location.name, "##A_LOCATION##": appointment.location.name,
"##A_LOCATION_OR_FLYINGTEAM##": str(appointment.flying_team) or appointment.location.name, "##A_LOCATION_OR_FLYINGTEAM##": unicode(appointment.flying_team) or appointment.location.name,
"##A_WORKER##": unicode(appointment.worker_assigned), "##A_WORKER##": unicode(appointment.worker_assigned),
'##A_WORKER_PHONE##': worker_phone_number, '##A_WORKER_PHONE##': worker_phone_number,
'##A_WORKER_EMAIL##': worker_email_address, '##A_WORKER_EMAIL##': worker_email_address,
......
...@@ -222,7 +222,7 @@ class RedcapConnector(object): ...@@ -222,7 +222,7 @@ class RedcapConnector(object):
return result return result
def create_redcap_link(self, pid, redcap_version, subject): def create_redcap_link(self, pid, redcap_version, subject):
return self.base_url + "/redcap_v" + redcap_version + "/DataEntry/index.php?pid=" + pid + "&id=" + \ return self.base_url + "/redcap_v" + redcap_version + "/DataEntry/index.php?pid=" + str(pid) + "&id=" + \
subject.nd_number + "&page=demographics" subject.nd_number + "&page=demographics"
def get_red_cap_subjects(self): def get_red_cap_subjects(self):
......
...@@ -267,7 +267,7 @@ desired effect ...@@ -267,7 +267,7 @@ desired effect
{% block footer %} {% block footer %}
<!-- To the right --> <!-- To the right -->
<div class="pull-right hidden-xs"> <div class="pull-right hidden-xs">
Version: <strong>0.11.2</strong> (4 May 2018) Version: <strong>0.11.3</strong> (3 Sep 2018)
</div> </div>
<!-- Default to the left --> <!-- Default to the left -->
......
# coding=utf-8
import StringIO import StringIO
from django.test import TestCase from django.test import TestCase
...@@ -9,7 +10,7 @@ from web.models.constants import MAIL_TEMPLATE_CONTEXT_APPOINTMENT, MAIL_TEMPLAT ...@@ -9,7 +10,7 @@ from web.models.constants import MAIL_TEMPLATE_CONTEXT_APPOINTMENT, MAIL_TEMPLAT
from web.models.mail_template import DATE_FORMAT_SHORT from web.models.mail_template import DATE_FORMAT_SHORT
from web.tests.functions import create_language, get_resource_path, create_appointment, create_user, \ from web.tests.functions import create_language, get_resource_path, create_appointment, create_user, \
create_study_subject, \ create_study_subject, \
create_visit create_visit, create_flying_team
class MailTemplateModelTests(TestCase): class MailTemplateModelTests(TestCase):
...@@ -79,6 +80,20 @@ class MailTemplateModelTests(TestCase): ...@@ -79,6 +80,20 @@ class MailTemplateModelTests(TestCase):
location = appointment.location.name location = appointment.location.name
self.check_doc_contains(doc, [worker_name, location]) self.check_doc_contains(doc, [worker_name, location])
def test_appointment_with_unicode_flying_team(self):
template_name_french = "test_fr"
appointment = create_appointment()
# noinspection PyNonAsciiChar
flying_team_name = u"Liège"
appointment.flying_team = create_flying_team(flying_team_name)
appointment_template_french = MailTemplate(name=template_name_french, language=self.french_language,
context=MAIL_TEMPLATE_CONTEXT_APPOINTMENT,
template_file=self.template_file)
stream = StringIO.StringIO()
appointment_template_french.apply(appointment, self.user, stream)
doc = Document(stream)
self.check_doc_contains(doc, [flying_team_name])
def test_apply_subject(self): def test_apply_subject(self):
template_name_french = "test_fr" template_name_french = "test_fr"
subject = create_study_subject() subject = create_study_subject()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment