Validate date format on new platform admin page

Check that the format of the dates entered is in the `YYYY-MM-DD` as
specified and show an error message if it is not. If the date was not in
the specified format, there would be no error message but the content of
the page would change which was misleading.
This commit is contained in:
Katie Smith
2018-06-29 15:28:25 +01:00
parent ca16bef7f7
commit 9c5fd5f23c
2 changed files with 4 additions and 3 deletions

View File

@@ -50,9 +50,11 @@ def platform_admin():
@login_required
@user_is_platform_admin
def platform_admin_new():
form = DateFilterForm(request.args)
form = DateFilterForm(request.args, meta={'csrf': False})
api_args = {}
form.validate()
if form.start_date.data:
api_args['start_date'] = form.start_date.data
api_args['end_date'] = form.end_date.data or datetime.utcnow().date()