kopia lustrzana https://github.com/wagtail/wagtail
fix issue for string representation of FormSubmission
- fixes #8927 - problem introduced in #8230pull/8943/head
rodzic
405af5d451
commit
1ebd88a47f
|
@ -59,7 +59,7 @@ class AbstractFormSubmission(models.Model):
|
|||
}
|
||||
|
||||
def __str__(self):
|
||||
return self.form_data
|
||||
return f"{self.form_data}"
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
|
|
@ -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):
|
||||
|
|
Ładowanie…
Reference in New Issue