1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #29109 -- Fixed the admin time picker widget for the Thai locale.

This commit is contained in:
Manatsawin Hanmongkolchai
2018-02-11 04:05:41 +07:00
committed by Tim Graham
parent b832de869e
commit 1a1264f149
3 changed files with 23 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import decimal
import gettext as gettext_module
import os
import pickle
import re
from contextlib import contextmanager
from importlib import import_module
from threading import local
@@ -1095,6 +1096,22 @@ class FormattingTests(SimpleTestCase):
with translation.override('fr', deactivate=True):
self.assertEqual('d/m/Y CUSTOM', get_format('CUSTOM_DAY_FORMAT'))
def test_admin_javascript_supported_input_formats(self):
"""
The first input format for DATE_INPUT_FORMATS, TIME_INPUT_FORMATS, and
DATETIME_INPUT_FORMATS must not contain %f since that's unsupported by
the admin's time picker widget.
"""
regex = re.compile('%([^BcdHImMpSwxXyY%])')
for language_code, language_name in settings.LANGUAGES:
for format_name in ('DATE_INPUT_FORMATS', 'TIME_INPUT_FORMATS', 'DATETIME_INPUT_FORMATS'):
with self.subTest(language=language_code, format=format_name):
formatter = get_format(format_name, lang=language_code)[0]
self.assertEqual(
regex.findall(formatter), [],
"%s locale's %s uses an unsupported format code." % (language_code, format_name)
)
class MiscTests(SimpleTestCase):