diff --git a/wagtail/wagtailforms/templates/wagtailforms/list.html b/wagtail/wagtailforms/templates/wagtailforms/list.html
index 243846615d..86f65f2570 100644
--- a/wagtail/wagtailforms/templates/wagtailforms/list.html
+++ b/wagtail/wagtailforms/templates/wagtailforms/list.html
@@ -2,7 +2,7 @@
-
+
{% endfor %}
diff --git a/wagtail/wagtailforms/views.py b/wagtail/wagtailforms/views.py
index 3146f457c9..a325f17c0e 100644
--- a/wagtail/wagtailforms/views.py
+++ b/wagtail/wagtailforms/views.py
@@ -1,3 +1,5 @@
+import datetime
+
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.http import Http404
from django.shortcuts import get_object_or_404, render, redirect
@@ -9,7 +11,7 @@ from django.utils.translation import ugettext as _
from wagtail.wagtailcore.models import Page
from wagtail.wagtailforms.models import FormSubmission, get_form_types
-
+from wagtail.wagtailforms.forms import SelectDateForm
def get_form_type_from_url_params(app_name, model_name):
"""
@@ -42,10 +44,23 @@ def list_submissions(request, app_label, model, id):
form_page = get_object_or_404(model, id=id)
submissions = FormSubmission.objects.filter(form_page=form_page)
-
+ select_date_form = SelectDateForm(request.GET)
+ if select_date_form.is_valid():
+ date_from = select_date_form.cleaned_data.get('date_from')
+ date_to = select_date_form.cleaned_data.get('date_to')
+ # careful: date_to should be increased by 1 day since the submit_time
+ # is a time so it will always be greater
+ date_to += datetime.timedelta(days=1)
+ if date_from and date_to:
+ submissions=submissions.filter(submit_time__range=[date_from, date_to] )
+ elif date_from and not date_to:
+ submissions=submissions.filter(submit_time__gte=date_from)
+ elif not date_from and date_to:
+ submissions=submissions.filter(submit_time__lte=date_to)
+
p = request.GET.get('p', 1)
paginator = Paginator(submissions, 20)
-
+
try:
submissions = paginator.page(p)
except PageNotAnInteger:
@@ -53,9 +68,9 @@ def list_submissions(request, app_label, model, id):
except EmptyPage:
submissions = paginator.page(paginator.num_pages)
-
return render(request, 'wagtailforms/form_index.html', {
'form_page': form_page,
+ 'select_date_form': select_date_form,
'submissions': submissions,
})