kopia lustrzana https://github.com/wagtail/wagtail
Display a comma separated string for fields returning content as lists
rodzic
d5d23b01a5
commit
78a2e8ae96
|
@ -43,6 +43,7 @@ Changelog
|
|||
* Fix: Page links within rich text now respect custom URLs defined on specific page models (Gary Krige, Huub Bouma)
|
||||
* Fix: Default avatar no longer visible when using a transparent gravatar image (Thijs Kramer)
|
||||
* Fix: Scrolling within the datetime picker is now usable again for touchpads (Ralph Jacobs)
|
||||
* Fix: List-based fields within form builder form submissions are now displayed as comma-separated strings rather than as Python lists (Christine Ho, Matt Westcott)
|
||||
|
||||
|
||||
1.9 (16.02.2017)
|
||||
|
|
|
@ -55,6 +55,7 @@ Bug fixes
|
|||
* Page links within rich text now respect custom URLs defined on specific page models (Gary Krige, Huub Bouma)
|
||||
* Default avatar no longer visible when using a transparent gravatar image (Thijs Kramer)
|
||||
* Scrolling within the datetime picker is now usable again for touchpads (Ralph Jacobs)
|
||||
* List-based fields within form builder form submissions are now displayed as comma-separated strings rather than as Python lists (Christine Ho, Matt Westcott)
|
||||
|
||||
|
||||
Upgrade considerations
|
||||
|
|
|
@ -170,6 +170,7 @@ class TestFormsSubmissionsList(TestCase, WagtailTestUtils):
|
|||
form_data=json.dumps({
|
||||
'your-email': "new@example.com",
|
||||
'your-message': "this is a fairly new message",
|
||||
'your-choices': ['foo', 'baz'],
|
||||
}),
|
||||
)
|
||||
new_form_submission.submit_time = '2014-01-01T12:00:00.000Z'
|
||||
|
@ -209,6 +210,9 @@ class TestFormsSubmissionsList(TestCase, WagtailTestUtils):
|
|||
self.assertTemplateUsed(response, 'wagtailforms/index_submissions.html')
|
||||
self.assertEqual(len(response.context['data_rows']), 2)
|
||||
|
||||
# check display of list values within form submissions
|
||||
self.assertContains(response, 'foo, baz')
|
||||
|
||||
def test_list_submissions_after_filter_form_submissions_for_user_hook(self):
|
||||
# Hook forbids to delete form submissions for everyone
|
||||
def construct_forms_for_user(user, queryset):
|
||||
|
@ -308,6 +312,7 @@ class TestFormsSubmissionsExport(TestCase, WagtailTestUtils):
|
|||
form_data=json.dumps({
|
||||
'your-email': "old@example.com",
|
||||
'your-message': "this is a really old message",
|
||||
'your-choices': ['foo', 'baz'],
|
||||
}),
|
||||
)
|
||||
old_form_submission.submit_time = '2013-01-01T12:00:00.000Z'
|
||||
|
@ -337,7 +342,7 @@ class TestFormsSubmissionsExport(TestCase, WagtailTestUtils):
|
|||
data_lines = response.content.decode().split("\n")
|
||||
|
||||
self.assertEqual(data_lines[0], 'Submission date,Your email,Your message,Your choices\r')
|
||||
self.assertEqual(data_lines[1], '2013-01-01 12:00:00+00:00,old@example.com,this is a really old message,None\r')
|
||||
self.assertEqual(data_lines[1], '2013-01-01 12:00:00+00:00,old@example.com,this is a really old message,"foo, baz"\r')
|
||||
self.assertEqual(data_lines[2], '2014-01-01 12:00:00+00:00,new@example.com,this is a fairly new message,None\r')
|
||||
|
||||
def test_list_submissions_csv_export_after_filter_form_submissions_for_user_hook(self):
|
||||
|
@ -355,7 +360,7 @@ class TestFormsSubmissionsExport(TestCase, WagtailTestUtils):
|
|||
data_lines = response.content.decode().split("\n")
|
||||
|
||||
self.assertEqual(data_lines[0], 'Submission date,Your email,Your message,Your choices\r')
|
||||
self.assertEqual(data_lines[1], '2013-01-01 12:00:00+00:00,old@example.com,this is a really old message,None\r')
|
||||
self.assertEqual(data_lines[1], '2013-01-01 12:00:00+00:00,old@example.com,this is a really old message,"foo, baz"\r')
|
||||
self.assertEqual(data_lines[2], '2014-01-01 12:00:00+00:00,new@example.com,this is a fairly new message,None\r')
|
||||
|
||||
with self.register_hook('filter_form_submissions_for_user', construct_forms_for_user):
|
||||
|
@ -391,7 +396,7 @@ class TestFormsSubmissionsExport(TestCase, WagtailTestUtils):
|
|||
data_lines = response.content.decode().split("\n")
|
||||
|
||||
self.assertEqual(data_lines[0], 'Submission date,Your email,Your message,Your choices\r')
|
||||
self.assertEqual(data_lines[1], '2013-01-01 12:00:00+00:00,old@example.com,this is a really old message,None\r')
|
||||
self.assertEqual(data_lines[1], '2013-01-01 12:00:00+00:00,old@example.com,this is a really old message,"foo, baz"\r')
|
||||
|
||||
def test_list_submissions_csv_export_with_range_filtering(self):
|
||||
response = self.client.get(
|
||||
|
|
|
@ -100,7 +100,10 @@ def list_submissions(request, page_id):
|
|||
data_row = []
|
||||
form_data = s.get_data()
|
||||
for name, label in data_fields:
|
||||
data_row.append(smart_str(form_data.get(name)))
|
||||
val = form_data.get(name)
|
||||
if isinstance(val, list):
|
||||
val = ', '.join(val)
|
||||
data_row.append(smart_str(val))
|
||||
writer.writerow(data_row)
|
||||
return response
|
||||
|
||||
|
@ -109,7 +112,12 @@ def list_submissions(request, page_id):
|
|||
data_rows = []
|
||||
for s in submissions:
|
||||
form_data = s.get_data()
|
||||
data_row = [form_data.get(name) for name, label in data_fields]
|
||||
data_row = []
|
||||
for name, label in data_fields:
|
||||
val = form_data.get(name)
|
||||
if isinstance(val, list):
|
||||
val = ', '.join(val)
|
||||
data_row.append(val)
|
||||
data_rows.append({
|
||||
"model_id": s.id,
|
||||
"fields": data_row
|
||||
|
|
Ładowanie…
Reference in New Issue