diff --git a/helpdesk/models.py b/helpdesk/models.py index dbed2a56..f111ed88 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -788,6 +788,9 @@ class Ticket(models.Model): self.modified = timezone.now() + if len(self.title) > 200: + self.title = self.title[:197] + "..." + super(Ticket, self).save(*args, **kwargs) @staticmethod diff --git a/helpdesk/tests/test_files/blank-body-with-attachment.eml b/helpdesk/tests/test_files/blank-body-with-attachment.eml index bab4f184..3683da7d 100644 --- a/helpdesk/tests/test_files/blank-body-with-attachment.eml +++ b/helpdesk/tests/test_files/blank-body-with-attachment.eml @@ -1,6 +1,6 @@ To: helpdesk@auto-mat.cz From: Timothy Hobbs -Subject: Attachment without body +Subject: Attachment without body - and a looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong subject Openpgp: preference=signencrypt Message-ID: Date: Fri, 15 Feb 2019 13:58:05 +0100 diff --git a/helpdesk/tests/test_get_email.py b/helpdesk/tests/test_get_email.py index fe8750cd..c113b04f 100644 --- a/helpdesk/tests/test_get_email.py +++ b/helpdesk/tests/test_get_email.py @@ -53,7 +53,13 @@ class GetEmailCommonTests(TestCase): with open(os.path.join(THIS_DIR, "test_files/blank-body-with-attachment.eml")) as fd: test_email = fd.read() ticket = helpdesk.email.object_from_message(test_email, self.queue_public, self.logger) - self.assertEqual(ticket.title, "Attachment without body") + + # title got truncated because of max_lengh of the model.title field + assert ticket.title == ( + "Attachment without body - and a loooooooooooooooooooooooooooooooooo" + "ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" + "ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo..." + ) self.assertEqual(ticket.description, "") def test_email_with_quoted_printable_body(self):