fix issue for string representation of FormSubmission

- fixes #8927
- problem introduced in #8230
pull/8943/head
LB Johnston 2022-08-04 08:25:57 +10:00 zatwierdzone przez Matt Westcott
rodzic 405af5d451
commit 1ebd88a47f
2 zmienionych plików z 21 dodań i 1 usunięć

Wyświetl plik

@ -59,7 +59,7 @@ class AbstractFormSubmission(models.Model):
}
def __str__(self):
return self.form_data
return f"{self.form_data}"
class Meta:
abstract = True

Wyświetl plik

@ -183,6 +183,26 @@ class TestFormSubmission(TestCase):
with self.assertRaises(ValidationError):
make_form_page(from_address="not an email")
def test_string_representation_form_submission(self):
"""
Ensure that a form submission can be logged / printed without error.
Broke when converting field to JSON - see #8927
"""
self.client.post(
"/contact-us/",
{
"your_email": "bob@example.com",
"your_message": "hello world",
"your_choices": {},
},
)
self.assertGreaterEqual(FormSubmission.objects.count(), 1)
submission = FormSubmission.objects.first()
self.assertIn("hello world", str(submission))
class TestFormWithCustomSubmission(TestCase, WagtailTestUtils):
def setUp(self):