Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #15234 -- Ensure that years in a date heirarchy don't use comma…

…s for thousand separators, regardless of the value of USE_THOUSAND_SEPARATOR. Thanks to Julien Phalip for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15451 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a105ca5d7a232edd4713f37fbbe9ee3fec5f9e77 1 parent 90a79ba
@freakboy3742 freakboy3742 authored
View
2  django/contrib/admin/templatetags/admin_list.py
@@ -261,7 +261,7 @@ def date_hierarchy(cl):
'show': True,
'back': {
'link': link({year_field: year_lookup}),
- 'title': year_lookup
+ 'title': str(year_lookup)
},
'choices': [{
'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}),
View
54 tests/regressiontests/admin_views/tests.py
@@ -2587,6 +2587,21 @@ class DateHierarchyTests(TestCase):
def setUp(self):
self.client.login(username='super', password='secret')
+ self.old_USE_THOUSAND_SEPARATOR = settings.USE_THOUSAND_SEPARATOR
+ self.old_USE_L10N = settings.USE_L10N
+ settings.USE_THOUSAND_SEPARATOR = True
+ settings.USE_L10N = True
+
+ def tearDown(self):
+ settings.USE_THOUSAND_SEPARATOR = self.old_USE_THOUSAND_SEPARATOR
+ settings.USE_L10N = self.old_USE_L10N
+
+ def assert_non_localized_year(self, url, year):
+ """Ensure that the year is not localized with
+ USE_THOUSAND_SEPARATOR. Refs #15234.
+ """
+ response = self.client.get(url)
+ self.assertNotContains(response, formats.number_format(year))
def assert_contains_year_link(self, response, date):
self.assertContains(response, '?release_date__year=%d"' % (date.year,))
@@ -2618,9 +2633,10 @@ def test_single(self):
"""
DATE = datetime.date(2000, 6, 30)
Podcast.objects.create(release_date=DATE)
- response = self.client.get(
- reverse('admin:admin_views_podcast_changelist'))
+ url = reverse('admin:admin_views_podcast_changelist')
+ response = self.client.get(url)
self.assert_contains_day_link(response, DATE)
+ self.assert_non_localized_year(url, 2000)
def test_within_month(self):
"""
@@ -2631,10 +2647,11 @@ def test_within_month(self):
datetime.date(2000, 6, 3))
for date in DATES:
Podcast.objects.create(release_date=date)
- response = self.client.get(
- reverse('admin:admin_views_podcast_changelist'))
+ url = reverse('admin:admin_views_podcast_changelist')
+ response = self.client.get(url)
for date in DATES:
self.assert_contains_day_link(response, date)
+ self.assert_non_localized_year(url, 2000)
def test_within_year(self):
"""
@@ -2645,12 +2662,13 @@ def test_within_year(self):
datetime.date(2000, 5, 3))
for date in DATES:
Podcast.objects.create(release_date=date)
- response = self.client.get(
- reverse('admin:admin_views_podcast_changelist'))
+ url = reverse('admin:admin_views_podcast_changelist')
+ response = self.client.get(url)
# no day-level links
self.assertNotContains(response, 'release_date__day=')
for date in DATES:
self.assert_contains_month_link(response, date)
+ self.assert_non_localized_year(url, 2000)
def test_multiple_years(self):
"""
@@ -2671,14 +2689,20 @@ def test_multiple_years(self):
# and make sure GET parameters still behave correctly
for date in DATES:
- response = self.client.get(
- '%s?release_date__year=%d' % (
- reverse('admin:admin_views_podcast_changelist'),
- date.year))
+ url = '%s?release_date__year=%d' % (
+ reverse('admin:admin_views_podcast_changelist'),
+ date.year)
+ response = self.client.get(url)
self.assert_contains_month_link(response, date)
-
- response = self.client.get(
- '%s?release_date__year=%d&release_date__month=%d' % (
- reverse('admin:admin_views_podcast_changelist'),
- date.year, date.month))
+ self.assert_non_localized_year(url, 2000)
+ self.assert_non_localized_year(url, 2003)
+ self.assert_non_localized_year(url, 2005)
+
+ url = '%s?release_date__year=%d&release_date__month=%d' % (
+ reverse('admin:admin_views_podcast_changelist'),
+ date.year, date.month)
+ response = self.client.get(url)
self.assert_contains_day_link(response, date)
+ self.assert_non_localized_year(url, 2000)
+ self.assert_non_localized_year(url, 2003)
+ self.assert_non_localized_year(url, 2005)
Please sign in to comment.
Something went wrong with that request. Please try again.