Skip to content

Commit

Permalink
Ensure form submission listing is explicitly ordered by submit_time
Browse files Browse the repository at this point in the history
  • Loading branch information
gasman authored and kaedroho committed Sep 27, 2016
1 parent 53abc74 commit 4edcb61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions wagtail/wagtailforms/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,9 @@ def setUp(self):
self.form_page = make_form_page()

# Add a couple of form submissions
old_form_submission = FormSubmission.objects.create(
page=self.form_page,
form_data=json.dumps({
'your-email': "old@example.com",
'your-message': "this is a really old message",
}),
)
old_form_submission.submit_time = '2013-01-01T12:00:00.000Z'
old_form_submission.save()
# (save new_form_submission first, so that we're more likely to reveal bugs where
# we're relying on the database's internal ordering instead of explicitly ordering
# by submit_time)

new_form_submission = FormSubmission.objects.create(
page=self.form_page,
Expand All @@ -180,6 +174,16 @@ def setUp(self):
new_form_submission.submit_time = '2014-01-01T12:00:00.000Z'
new_form_submission.save()

old_form_submission = FormSubmission.objects.create(
page=self.form_page,
form_data=json.dumps({
'your-email': "old@example.com",
'your-message': "this is a really old message",
}),
)
old_form_submission.submit_time = '2013-01-01T12:00:00.000Z'
old_form_submission.save()

# Login
self.login()

Expand Down
2 changes: 1 addition & 1 deletion wagtail/wagtailforms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def list_submissions(request, page_id):

data_fields = form_page.get_data_fields()

submissions = form_submission_class.objects.filter(page=form_page)
submissions = form_submission_class.objects.filter(page=form_page).order_by('submit_time')
data_headings = [label for name, label in data_fields]

select_date_form = SelectDateForm(request.GET)
Expand Down

0 comments on commit 4edcb61

Please sign in to comment.