From 7e138b7cf2d494ebb0df4db29d976a7e871cf831 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Fri, 15 Dec 2017 11:18:35 +0100 Subject: [PATCH] bug fix when serializing subjects --- smash/web/api_views/subject.py | 2 +- smash/web/tests/api_views/test_subject.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/smash/web/api_views/subject.py b/smash/web/api_views/subject.py index 6c9bdcbf..2cf6c5ec 100644 --- a/smash/web/api_views/subject.py +++ b/smash/web/api_views/subject.py @@ -356,7 +356,7 @@ def serialize_subject(study_subject): contact_attempts = ContactAttempt.objects.filter(subject=study_subject).order_by("-datetime_when") if len(contact_attempts) > 0: last_contact_attempt = contact_attempts[0] - last_contact_attempt_string = serialize_datetime(last_contact_attempt.datetime_when) + "<br/>" + str( + last_contact_attempt_string = serialize_datetime(last_contact_attempt.datetime_when) + "<br/>" + unicode( last_contact_attempt.worker) + "<br/> Success: " + bool_to_yes_no( last_contact_attempt.success) + "<br/>" + last_contact_attempt.comment diff --git a/smash/web/tests/api_views/test_subject.py b/smash/web/tests/api_views/test_subject.py index 4276b734..5e3de96a 100644 --- a/smash/web/tests/api_views/test_subject.py +++ b/smash/web/tests/api_views/test_subject.py @@ -104,6 +104,14 @@ class TestSubjectApi(LoggedInWithWorkerTestCase): response = self.client.get(reverse('web.api.subjects', kwargs={'type': SUBJECT_LIST_GENERIC})) self.assertEqual(response.status_code, 200) + def test_subjects_general_with_special_characters(self): + contact_attempt = create_contact_attempt(subject=self.study_subject) + contact_attempt.worker.first_name = "Ã special character" + contact_attempt.worker.save() + response = self.client.get(reverse('web.api.subjects', kwargs={'type': SUBJECT_LIST_GENERIC})) + self.assertEqual(response.status_code, 200) + logger.debug(response.content) + def test_subjects_voucher_almost_expired(self): response = self.client.get(reverse('web.api.subjects', kwargs={'type': SUBJECT_LIST_VOUCHER_EXPIRY})) self.assertEqual(response.status_code, 200) -- GitLab