From 2000f375cde88358cdc66f775f4de14df1234f72 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Tue, 14 Feb 2012 21:29:50 +0000 Subject: Fixed #17675 -- Changed the implementation of the {% regroup %} template tag to use the context properly when resolving expressions. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17522 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/templates/tests.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index b067cb55b0..631c58c3a3 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -8,7 +8,7 @@ if __name__ == '__main__': # before importing 'template'. settings.configure() -from datetime import datetime, timedelta +from datetime import date, datetime, timedelta import time import os import sys @@ -1376,6 +1376,33 @@ class Templates(unittest.TestCase): '{% endfor %},' '{% endfor %}', {}, ''), + + # Regression tests for #17675 + # The date template filter has expects_localtime = True + 'regroup03': ('{% regroup data by at|date:"m" as grouped %}' + '{% for group in grouped %}' + '{{ group.grouper }}:' + '{% for item in group.list %}' + '{{ item.at|date:"d" }}' + '{% endfor %},' + '{% endfor %}', + {'data': [{'at': date(2012, 2, 14)}, + {'at': date(2012, 2, 28)}, + {'at': date(2012, 7, 4)}]}, + '02:1428,07:04,'), + # The join template filter has needs_autoescape = True + 'regroup04': ('{% regroup data by bar|join:"" as grouped %}' + '{% for group in grouped %}' + '{{ group.grouper }}:' + '{% for item in group.list %}' + '{{ item.foo|first }}' + '{% endfor %},' + '{% endfor %}', + {'data': [{'foo': 'x', 'bar': ['ab', 'c']}, + {'foo': 'y', 'bar': ['a', 'bc']}, + {'foo': 'z', 'bar': ['a', 'd']}]}, + 'abc:xy,ad:z,'), + ### SSI TAG ######################################################## # Test normal behavior -- cgit v1.3