Commit Graph

471 Commits

Author SHA1 Message Date
Claude Paroz ed77bea582 Refs #28502 -- Complemented stringformat tuple handling/test.
An additional test and a code change were suggested in a late review.
2017-08-22 08:45:08 -04:00
Srinivas Reddy Thatiparthy 4ead705cb3 Fixed #28502 -- Made stringformat template filter accept tuples 2017-08-21 09:04:43 +02:00
Srinivas Reddy Thatiparthy a64f88f5be Refs #28502 -- Completed stringformat filter tests 2017-08-19 21:22:59 +02:00
Mads Jensen a51c4de194 Used assertRaisesMessage() to test Django's error messages. 2017-07-29 19:07:23 -04:00
John D'Ambrosio be68c0bf63 Fixed #28071 -- Fixed {% extends %} origin history. 2017-06-13 12:50:54 -04:00
Jon Dufresne 2c69824e5a Refs #23968 -- Removed unnecessary lists, generators, and tuple calls. 2017-06-01 19:08:59 -04:00
Alexander Allakhverdiyev a7c6c705e8 Fixed #28129 -- Allowed custom template tags to use keyword-only arguments. 2017-05-11 10:09:44 -04:00
kapil garg dbfcedb499 Fixed #28001 -- Updated comment and tested context popping in ForNode.render(). 2017-04-06 19:04:29 -04:00
kapil garg 002fe07622 Fixed #27974 -- Kept resolved templates constant during one rendering cycle.
Thanks Florian Apolloner for the initial patch.
2017-04-03 22:29:39 -04:00
Carlton Gibson 6b3724fa11 Fixed #27359 -- Made Engine.get_default() return the first DjangoTemplates engine if multiple are defined. 2017-03-31 17:26:42 -04:00
Carlton Gibson 7019724101 Added tests for template's Engine.get_default(). 2017-03-31 10:59:00 -04:00
Tim Graham e643ba8bcf Fixed #27956 -- Fixed display of errors in an {% extends %} child.
Thanks Ling-Xiao Yang for the report and test, and
Preston Timmons for the fix.
2017-03-25 08:22:12 -04:00
Bo Marchman 7a7b331cd5 Fixed #27882 -- Allowed {% cache %} to cache indefinitely. 2017-03-15 13:01:21 -04:00
Vytis Banaitis 3dcc351691 Refs #23919 -- Used yield from. 2017-02-23 20:06:01 -05:00
Tim Graham fe2d288434 Fixed #27722 -- Reallowed using django.Template in {% include %}. 2017-02-11 06:51:57 -05:00
Claude Paroz 3a148f958d Refs #27795 -- Removed force_text from the template layer
Thanks Tim Graham for the review.
2017-02-07 17:14:02 +01:00
Ryan O’Hara 7c4289d0b9 Fixed #27783 -- Switched VariableDoesNotExist.__str__() to repr() context.
Using __str__() and then repr'ing the result looks strange and can lead
to recursive rendering of forms.
2017-02-06 17:53:21 -05:00
Mads Jensen ce69a421f6 Added tests for various __repr__() methods. 2017-02-04 11:29:39 -05:00
Tim Graham 29f607927f Fixed spelling of "nonexistent". 2017-02-03 08:01:45 -05:00
Vytis Banaitis d1bab24e01 Refs #23919, #27778 -- Removed obsolete mentions of unicode. 2017-01-26 08:19:27 -05:00
chillaranand d6eaf7c018 Refs #23919 -- Replaced super(ClassName, self) with super(). 2017-01-25 12:23:46 -05:00
Claude Paroz 2366100872 Removed unneeded force_text calls in the test suite 2017-01-24 18:45:54 +01:00
Tim Graham d170c63351 Refs #23919 -- Removed misc references to Python 2. 2017-01-21 20:02:00 -05:00
Tim Graham 8249c5b382 Added a missing floatformat test and simplified another. 2017-01-21 13:06:52 -05:00
Claude Paroz 289fc1bfa5 Refs #23919 -- Removed str_prefix usage 2017-01-20 15:43:28 +01:00
Tim Graham 4e729feaa6 Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.
These functions do nothing on Python 3.
2017-01-20 08:01:02 -05:00
Tim Graham 109b33f64c Refs #23919 -- Simplified assertRaisesRegex()'s that accounted for Python 2. 2017-01-20 08:49:47 +01:00
Simon Charette cecc079168 Refs #23919 -- Stopped inheriting from object to define new style classes. 2017-01-19 08:39:46 +01:00
Claude Paroz 2b281cc35e Refs #23919 -- Removed most of remaining six usage
Thanks Tim Graham for the review.
2017-01-18 21:33:28 +01:00
Claude Paroz 7b2f2e74ad Refs #23919 -- Removed six.<various>_types usage
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18 20:18:46 +01:00
Claude Paroz c716fe8782 Refs #23919 -- Removed six.PY2/PY3 usage
Thanks Tim Graham for the review.
2017-01-18 16:21:28 +01:00
Claude Paroz f3c43ad1fd Refs #23919 -- Removed python_2_unicode_compatible decorator usage 2017-01-18 13:44:34 +01:00
Claude Paroz d7b9aaa366 Refs #23919 -- Removed encoding preambles and future imports 2017-01-18 09:55:19 +01:00
Tim Graham d334f46b7a Refs #26601 -- Removed support for old-style middleware using settings.MIDDLEWARE_CLASSES. 2017-01-17 20:52:04 -05:00
Tim Graham 60ca37d2e5 Refs #24046 -- Removed mark_for_escaping() per deprecation timeline. 2017-01-17 20:52:04 -05:00
Tim Graham 740f63a3df Refs #26263 -- Removed deprecated Context.has_key(). 2017-01-17 20:52:03 -05:00
Tim Graham 8377abd59e Refs #25120 -- Removed template.loaders.eggs.Loader per deprecation timeline. 2017-01-17 20:52:00 -05:00
Tim Graham 5d8da093a9 Refs #15053 -- Removed support for non-recursive template loading.
Per deprecation timeline.
2017-01-17 20:52:00 -05:00
Tim Graham f032bbc8b1 Refs #18651 -- Removed assignment_tag per deprecation timeline. 2017-01-17 14:09:28 -05:00
Andy Craze 97c1931c4f Fixed #24423 -- Reorganized i18n tag tests. 2017-01-06 10:33:07 -05:00
Tim Martin e3f095b086 Fixed #26478 -- Made {% for %} reject invalid unpacking vars with quotes or vertical bars. 2016-12-30 09:22:40 -05:00
Tim Graham 9f16ea21c4 Used assertRaisesMessage() in {% for %} tests. 2016-12-30 09:22:04 -05:00
Preston Timmons 0b4d517263 Fixed #27584 -- Fixed display of render time template errors. 2016-12-20 10:36:33 -05:00
Tim Graham 1a04b1762b Refs #25484 -- Made non-staticfiles {% static %} tag quote its output. 2016-12-19 16:18:06 -05:00
Tim Graham a85e84212e Refs #21221 -- Prevented {% static %} tests from using contrib.staticfiles. 2016-12-19 12:37:38 -05:00
alix- 374e6230ca Fixed #25484 -- Made {% static %} render escaped URLs. 2016-12-17 10:03:44 -05:00
Tim Graham 92c5eeac33 Fixed #27598 -- Allowed specifying directories for a filesystem template loader.
Thanks Carl Meyer for review.
2016-12-14 10:33:51 -05:00
Tim Graham b5f0b3478d Fixed #27579 -- Added aliases for Python 3's assertion names in SimpleTestCase. 2016-12-07 17:42:31 -05:00
Kosei Kitahara f095b249ba Fixed #27517 -- Fixed charset param in SimpleTemplateResponse.__init__(). 2016-11-24 05:56:39 -05:00
Tim Graham 41759c9082 Refs #27394 -- Removed @expectedFailure from a floatformat test. 2016-11-22 09:47:12 -05:00
Mariusz Felisiak 12f7928f5a Fixed #27394 -- Added scientific notation support for big integers in floatformat filter. 2016-11-15 09:07:15 -05:00
Ramin Farajpour Cami 0a63ef3f61 Fixed #27463 -- Fixed E741 flake8 warnings. 2016-11-14 17:40:28 -05:00
Ramin Farajpour Cami 967be82443 Fixed E305 flake8 warnings. 2016-11-14 12:30:46 -05:00
za 321e94fa41 Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings. 2016-11-10 21:30:21 -05:00
Tim Graham 8119b679eb Refs #27025 -- Fixed "invalid escape sequence" warnings in Python 3.6.
http://bugs.python.org/issue27364
2016-09-17 15:44:06 -04:00
Jon Dufresne 331ca5391e Fixed #27175 -- Deprecated silencing exceptions from the {% include %} template tag.
Thanks Tim Graham for the review.
2016-09-08 18:24:22 -07:00
Tim Graham 277fe2e8f2 Fixed #25788 -- Enabled the cached template loader if debug is False. 2016-09-03 09:06:33 -04:00
Sergei Maertens 32c02f2a0e Fixed #5908 -- Added {% resetcycle %} template tag.
Thanks to Simon Litchfield for the report, Uninen for the initial
patch, akaihola, jamesp, b.schube, and Florian Appoloner for
subsequent patches, tests, and documentation.
2016-09-01 15:52:21 -04:00
Tim Graham 59afe61a97 Fixed #27140 -- Prevented template rendering from hiding a property's TypeError. 2016-08-31 13:44:38 -04:00
Baptiste Mispelon 61b45dff6b Fixed #27126 -- Made {% regroup %} return a namedtuple to ease unpacking. 2016-08-26 16:59:21 -04:00
Tim Graham 937d752d3d Fixed #27058 -- Reallowed the {% for %} tag to unpack any iterable.
Thanks Sergei Maertens for the report and patch.
2016-08-15 15:39:22 -04:00
Alexander Schrijver 3ae3a1f9fa Fixed #26830 -- Prevented the 'with' templatetag from resetting the cycle variable to its initial state. 2016-08-09 09:05:17 -04:00
Alexander Schrijver 31e053edfa Refs #26830 -- Added a test for a named cycle template tag inside an ifchanged block and a for loop. 2016-08-09 08:47:09 -04:00
Raphaël Hertzog 8e5cbc884f Fixed #26923 -- Fixed template_tests with numpy < 1.9.0. 2016-07-21 12:59:55 -04:00
Baptiste Mispelon 418658f453 Fixed numpy deprecation warning silencing in template_tests. 2016-07-09 10:23:58 -04:00
Jon Dufresne 4f336f6652 Fixed #26747 -- Used more specific assertions in the Django test suite. 2016-06-16 14:19:18 -04:00
inondle 93c312cc9c Fixed #26573 -- Added descriptive error message for malformed if/else/elif template tags. 2016-05-27 18:12:56 -04:00
Tim Graham ece4d24f8e Refs #26601 -- Deprecated old-style middleware. 2016-05-17 07:22:26 -04:00
Florian Apolloner 9baf692a58 Fixed #26601 -- Improved middleware per DEP 0005.
Thanks Tim Graham for polishing the patch, updating the tests, and
writing documentation. Thanks Carl Meyer for shepherding the DEP.
2016-05-17 07:22:22 -04:00
Tim Graham 60b095cc4c Refs #24046 -- Fixed a template test when run in reverse. 2016-05-11 11:41:10 -04:00
Tim Graham 2f0e0eee45 Fixed #24046 -- Deprecated the "escape" half of utils.safestring. 2016-05-10 12:46:47 -04:00
Simon Charette 207c5b4acd
Fixed #26603 -- Forced lazy template names to text when computing cache key.
Refs #26536.

Thanks Sylvain Fankhauser for the very detailed report.
2016-05-10 10:03:01 -04:00
Vitaly Bogomolov aec4f97555 Fixed #26402 -- Added relative path support in include/extends template tags. 2016-05-07 16:21:57 -04:00
Alasdair Nicol dac075e910 Refs #26479 -- Documented is/is not if tag operator behavior for nonexistent variables. 2016-04-29 12:38:46 -04:00
Alasdair Nicol 246020efc5 Added tests for if tag's != operator. 2016-04-29 12:30:32 -04:00
Simon Charette bd145e7209 Fixed #26536 -- Preserved leading dashes of the cached template loader keys.
Thanks Anders Roos for the report.
2016-04-24 22:15:45 -04:00
Alasdair Nicol c16b9dd8e0 Fixed #26479 -- Added 'is not' operator to the if tag. 2016-04-09 13:01:15 -04:00
amureki f8bbba8060 Fixed #26403 -- Removed translated content in "Invalid block tag" message. 2016-04-09 09:31:05 -04:00
Tim Graham 92053acbb9 Fixed E128 flake8 warnings in tests/. 2016-04-08 10:12:33 -04:00
Alex Hill ecb59cc657 Fixed #26306 -- Fixed memory leak in cached template loader. 2016-03-16 12:37:57 -04:00
Ivan Tsouvarev 8890c533e0 Fixed #26280 -- Fixed cached template loader crash when loading nonexistent template. 2016-02-26 08:02:10 -05:00
Andrew Kuchev e81d1c995c Fixed #25670 -- Allowed dictsort to sort a list of lists.
Thanks Tim Graham for the review.
2016-02-23 12:15:08 -05:00
Tim Graham cdbd8745f6 Fixed #26263 -- Deprecated Context.has_key() 2016-02-23 08:08:55 -05:00
Jon Dufresne dec334cb66 Fixed #26193 -- Made urlize() trim multiple trailing punctuation. 2016-02-15 09:10:15 -05:00
Tim Graham 406675b1a0 Fixed #26176 -- Fixed E123 flake8 warnings. 2016-02-05 15:11:07 -05:00
Claude Paroz be9bd3348d Fixed #25758 -- Defaulted to current language FORMATs in date/time filters
Thanks Ali Lozano for the report and the initial patch, and Tim Graham for
the review.
2016-01-30 17:04:47 +01:00
Hasan 3d0dcd7f5a Refs #26022 -- Used context manager version of assertRaises in tests. 2016-01-29 12:32:18 -05:00
Preston Timmons cfda1fa3f8 Fixed #25848 -- Set template origin on each node.
Prior to 55f12f8709, the template origin was available on each node via
`self.token.source[0]`. This behavior was removed when debug handling was
simplified, but 3rd-party debugging tools still depend on its presence.
This updates the Parser to set origin on individual nodes. This enables the
source template to be determined even when template extending or including is
used.
2016-01-26 06:23:27 -05:00
Preston Timmons c00ae7f58c Fixed #26118 -- Added 'is' operator to if template tag. 2016-01-22 15:35:28 -05:00
Marten Kenbeek 16411b8400 Fixed #26013 -- Moved django.core.urlresolvers to django.urls.
Thanks to Tim Graham for the review.
2015-12-31 14:21:29 -05:00
Iacopo Spalletti d693074d43 Fixed #20223 -- Added keep_lazy() as a replacement for allow_lazy().
Thanks to bmispelon and uruz for the initial patch.
2015-12-12 14:46:48 -05:00
Jaap Roes c6ea4ed5d2 Fixed #25825 -- Implemented __ne__() for template Origin 2015-12-03 15:59:34 -05:00
Josh Soref 93452a70e8 Fixed many spelling mistakes in code, comments, and docs. 2015-12-03 12:48:24 -05:00
Alex Morozov 13dba4dba3 Fixed #25780 -- Removed redundant status code assertions from tests 2015-11-21 18:12:33 +01:00
Tim Graham 20d2778597 Removed obsolete comments about Django 1.10 in two test files. 2015-11-17 10:42:22 -05:00
Sambhav Satija ce7dd1273e Fixed #25441 -- Added support for negative filesize to filesizeformat template filter.
Thanks Andrey Yakovlev for the initial patch.
2015-10-27 10:35:45 -04:00
Marten Kenbeek 34af2bc523 Fixed #25610 -- Reverted removal of request.current_app in {% url %} tag.
The deprecation removal in 5e450c52aa
removed too much.
2015-10-26 10:42:20 -04:00
Pindi Albert 9f2881deb1 Fixed #25423 -- Made error message for unknown template tag more helpful. 2015-10-05 17:21:35 -04:00
Tim Graham 2ccfac1a65 Refs #23913 -- Removed support for a single equals sign in {% if %} tag.
Per deprecation timeline.
2015-09-23 19:31:11 -04:00
Tim Graham 9af3c6b9ce Made template response APIs enforce the use of dict and backend-specific template objects.
Per deprecation timeline; refs 79deb6a071.
2015-09-23 19:31:11 -04:00
Tim Graham 9114fe8ada Removed support for passing a context to a generic Template.render().
Per deprecation timeline; refs a3e783fe11.
2015-09-23 19:31:11 -04:00
Tim Graham 9023696613 Removed dictionary and context_instance parameters for render functions.
Per deprecation timeline.
2015-09-23 19:31:11 -04:00
Tim Graham b3641512c8 Removed dirs parameter in template engine methods and related funtions.
Per deprecation timeline.
2015-09-23 19:31:11 -04:00
Tim Graham 5e450c52aa Removed current_app argument to render() and TemplateResponse().
Per deprecation timeline.
2015-09-23 19:31:10 -04:00
Tim Graham 3bbebd06ad Refs #13408 -- Made unpacking mismatch an exception in {% for %} tag per deprecation timeline. 2015-09-23 19:31:09 -04:00
Tim Graham 222d063301 Refs #23269 -- Removed the removetags template tag and related functions per deprecation timeline. 2015-09-23 19:31:09 -04:00
Tim Graham 785cc71d5b Refs #22384 -- Removed the ability to reverse URLs by dotted path per deprecation timeline. 2015-09-23 19:31:09 -04:00
Tim Graham 9a3dfa2a52 Refs #23261 -- Removed old style list syntax for unordered_list filter
Per deprecation timeline.
2015-09-23 19:31:09 -04:00
Tim Graham 27b2321793 Refs #24451 -- Removed comma-separated {% cycle %} syntax per deprecation timeline. 2015-09-23 19:31:09 -04:00
Tim Graham 04ee4059d7 Refs #24022 -- Removed the ssi tag per deprecation timeline. 2015-09-23 19:31:09 -04:00
Tim Graham 57039f9661 Refs #22306 -- Removed cycle/firstof template tags from "future".
Per deprecation timeline.
2015-09-23 19:31:09 -04:00
Nick Johnson 392f64842f Fixed #25373 -- Added warning logging for exceptions during {% include %} tag rendering. 2015-09-21 19:57:12 -04:00
Nick Johnson 85c52743f7 Refs #18773 -- Improved template variable exception logging message. 2015-09-21 19:27:01 -04:00
Thomas Orozco d49667ef26 Refs #25422 -- Added a test for a template tag with type annotations.
This doesn't work in Django 1.8 but was fixed in Django 1.9 as a
side effect of another change.
2015-09-18 08:10:38 -04:00
Dave Smith b53b4d5c10 Fixed #25404 -- Added line numbers to TemplateSyntaxError strings.
This makes it much easier to diagnose a test failure when all
you have is the stack trace from an uncaught TemplateSyntaxError.
2015-09-15 12:25:13 -04:00
Dražen Odobašić b1e33ceced Fixed #23395 -- Limited line lengths to 119 characters. 2015-09-12 11:40:50 -04:00
Buddy Lindsey, Jr ec704371e3 Fixed #24765 -- Allowed template context updates to flatten a Context. 2015-09-11 14:52:13 -04:00
Doug Beck b7508896fb Fixed #24257 -- Corrected i18n handling of percent signs.
Refactored tests to use a sample project.

Updated extraction:
* Removed special handling of single percent signs.
* When extracting messages from template text, doubled all percent signs
  so they are not interpreted by gettext as string format flags. All
  strings extracted by gettext, if containing a percent sign, will now
  be labeled "#, python-format".

Updated translation:
* Used "%%" for "%" in template text before calling gettext.
* Updated {% trans %} rendering to restore "%" from "%%".
2015-08-12 10:23:34 -04:00
Tim Graham a3830f6d66 Refs #25236 -- Removed ifequal/ifnotequal usage. 2015-08-08 07:33:15 -04:00
Claude Paroz 64982cc2fb Updated Wikipedia links to use https 2015-08-08 12:02:32 +02:00
Marten Kenbeek bc7923beff Fixed #24127 -- Changed the default current_app to the current namespace.
Changed the url template tag to use request.resolver_match.namespace as a
default for the current_app argument if request.current_app is not set.
2015-07-27 09:14:48 -04:00
Luke Plant 8a5eadd140 Corrected HTML-escaping behaviour of url template tag.
Due to the URL encoding applied by the tag for all parameters that might be
partly controllable by an end-user, there are no XSS/security problems
caused by this bug, only invalid HTML.
2015-07-21 14:04:58 +01:00
Tim Graham 1fed8dd715 Fixed #25120 -- Deprecated egg template loader. 2015-07-16 09:32:42 -04:00
Matthew Somerville 839edcebb3 Fixed #21695 -- Added asvar option to blocktrans.
Thanks Bojan Mihelac for the initial patch.
2015-07-01 10:03:00 -04:00
Ned Batchelder 3b81dbe844 Used %r in the TextNode repr to show newlines better. 2015-06-30 09:54:18 -04:00
Luke Plant aef2a0ec59 Fixed #25018 -- Changed simple_tag to apply conditional_escape() to its output.
This is a security hardening fix to help prevent XSS (and incorrect HTML)
for the common use case of simple_tag.

Thanks to Tim Graham for the review.
2015-06-29 08:16:19 -04:00
Noam e291fc4757 Fixed #25031 -- Fixed a regression in the unordered_list template filter. 2015-06-27 09:37:41 -04:00
Tim Graham aaacaeb096 Renamed RemovedInDjangoXYWarnings for new roadmap.
Forwardport of ae1d663b79
from stable/1.8.x plus more.
2015-06-24 16:08:20 -04:00
Matthew Somerville a391b17ad2 Fixed #23516 -- Added caching of include tag Template objects
This also speeds up for loops that render the same template
multiple times.
2015-06-06 09:25:11 -04:00
Tomáš Ehrlich 002b3d87b5 Fixed #24230 -- Added translated language name for i18n template tag/filter. 2015-06-02 16:04:01 -04:00
Paweł Marczewski 300e8baf94 Fixed #24847 -- Prevented items set on a RequestContext from being lost. 2015-05-27 10:04:57 -04:00
Preston Timmons 655f524915 Fixed #17085, #24783 -- Refactored template library registration.
* Converted the ``libraries`` and ``builtins`` globals of
  ``django.template.base`` into properties of the Engine class.
* Added a public API for explicit registration of libraries and builtins.
2015-05-21 09:12:06 -05:00
Simon Charette 8bf1449edb Refs #24652 -- Converted a template test to avoid executing queries. 2015-05-20 12:50:40 -04:00
Tim Graham 3b133ffb8b Fixed template_tests failure on Windows. 2015-04-28 07:55:27 -04:00
Preston Timmons fc21471526 Fixed #15053 -- Enabled recursive template loading. 2015-04-22 14:49:00 -05:00
Preston Timmons fb267a1d85 Updated template tests to create their own engine.
This continues work to treat Django templates as a library.
2015-04-20 09:11:37 -05:00
Tommy Beadle 6bfd864ff2 Fixed #24603 -- Allowed Context.update() to be used as a context manager. 2015-04-14 08:01:16 -04:00
Craig Oldford 75bc5bc634 Fixed #12199 -- Added the ability to use "as" with the firstof template tag. 2015-04-14 07:19:47 -04:00
Preston Timmons 0808ccce38 Fixed #23441, #24555 -- Improved the behavior of InclusionNode.
This change:

* Makes the InclusionNode cache-safe by removing render-time side effects
  to its nodelist.
* Ensures the render_context stack is properly scoped and reset by updating
  the render call to use Template.render rather than Nodelist.render.
2015-04-01 13:02:19 -04:00
Caroline Simpson dc5b01ad05 Fixed #18773 -- Added logging for template variable resolving
Added a django.template logger without a default handler. Added
logging if there is an exception while resolving variables in a
template.
2015-03-27 19:19:48 -04:00
Preston Timmons 55f12f8709 Cleaned up the template debug implementation.
This patch does three major things:

* Merges the django.template.debug implementation into django.template.base.

* Simplifies the debug implementation.

  The old implementation copied debug information to every token and node.
  The django_template_source attribute was set in multiple places, some
  quite hacky, like django.template.defaulttags.ForNode.

  Debug information is now annotated in two high-level places:

  * Template.compile_nodelist for errors during parsing
  * Node.render_annotated for errors during rendering

  These were chosen because they have access to the template and context
  as well as to all exceptions that happen during either the parse or
  render phase.

* Moves the contextual line traceback information creation from
  django.views.debug into django.template.base.Template. The debug views now
  only deal with the presentation of the debug information.
2015-03-20 08:58:07 -04:00
Preston Timmons 388e79e9fc Fixed #24493 -- Added BaseContext.setdefault() 2015-03-16 13:13:02 -04:00
Tim Graham 3ed9c7bdfe Fixed #24471 -- Enhanced urlize regex to exclude quotes and angle brackets. 2015-03-10 19:24:46 -04:00
Tim Graham 7b1a67cce5 Fixed escaping regression in urlize filter.
Now that the URL is always unescaped as of refs #22267,
we should re-escape it before inserting it into the anchor.
2015-03-10 18:58:34 -04:00
Erik Romijn fa350e2f30 Fixed #24464 -- Made built-in HTML template filter functions escape their input by default.
This may cause some backwards compatibility issues, but may also
resolve security issues in third party projects that fail to heed warnings
in our documentation.

Thanks Markus Holtermann for help with tests and docs.
2015-03-09 09:29:58 -04:00
Tim Graham c36b60836b Fixed #24451 -- Deprecated comma-separated {% cycle %} syntax. 2015-03-07 07:42:39 -05:00
Claude Paroz ec808e807a Fixed urlize regression with entities in query strings
Refs #22267.
Thanks Shai Berger for spotting the issue and Tim Graham for the
initial patch.
2015-03-06 22:20:14 +01:00
Preston Timmons fb7d681705 Fixed test_notafile_error to pass on Windows.
This test failed because a different error code is raised on Windows when
opening a directory. Since the particular message isn't as important to this
test as the fact that the original IOError is reraised, this fixes the test
by making the assertion more generic.
2015-03-05 12:14:19 -05:00
Preston Timmons 70123cf084 Fixed #24399 -- Made filesystem loaders use more specific exceptions. 2015-03-03 21:20:46 +01:00
Preston Timmons 358850781f Fixed #24372 - Replaced TokenParser usage with traditional parsing. 2015-03-02 18:25:28 -05:00
Preston Timmons 80d6b6b863 Fixed #24409 -- Combined the app_directories and filesystem loader implementation.
Besides the directories they look in, these two loaders are functionally
the same. This removes unnecessary code duplication between the two.
2015-03-02 07:53:58 -05:00
Preston Timmons 8e129b42ad Cleaned up template directory handling in template tests. 2015-02-24 14:00:03 +01:00
Preston Timmons 32c108a221 Combined TemplateTests and TemplateRegressionTests. 2015-02-24 14:00:03 +01:00
Preston Timmons 25a0b5cdcd Moved test_token_smart_split into ParserTests. 2015-02-24 14:00:03 +01:00
Preston Timmons 3d8fee6051 Moved ifchanged tests into syntax_tests/test_if_changed.py. 2015-02-24 14:00:02 +01:00
Preston Timmons f6d087b628 Moved cache tests into syntax_tests/test_cache.py. 2015-02-24 14:00:02 +01:00
Preston Timmons 250a3d1993 Moved RequestContextTests into test_context. 2015-02-24 14:00:02 +01:00
Preston Timmons ff67ce5076 Moved TemplateTagLoading cases into test_custom. 2015-02-24 14:00:02 +01:00
Preston Timmons 06ffc764a9 Moved include tests into syntax_tests/test_include.py. 2015-02-24 14:00:02 +01:00
Preston Timmons 441a47e1ef Moved ssi tests into syntax_tests/test_ssi.py. 2015-02-24 14:00:02 +01:00
Preston Timmons 1827aa9024 Cleaned up template loader tests. 2015-02-24 14:00:02 +01:00
Aymeric Augustin 1bfcc950ab Set context.template instead of context.engine while rendering.
This opens more possibilities, like accessing context.template.origin.

It also follows the chain of objects instead of following a shortcut.
2015-02-19 22:08:11 +01:00
Tim Graham 307c0f299a Refs #24324 -- Fixed Python 2 test failures when path to Django source contains non-ASCII characters. 2015-02-17 19:03:03 -05:00
Aymeric Augustin 15b711b5ee Deprecated TEMPLATE_DEBUG setting. 2015-02-15 20:47:04 +01:00
Aymeric Augustin 47ee7b48ad Fixed #24338 -- Accepted Template wrapper in {% extends %}.
Explicitly checking for django.template.Template subclasses is
preferrable to duck-typing because both the django.template.Template and
django.template.backends.django.Template have a render() method.

Thanks spectras for the report.
2015-02-14 10:21:06 +01:00
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Aymeric Augustin 31d3a35579 Fixed #24273 -- Allowed copying RequestContext more than once.
Thanks Collin Anderson for the report.
2015-02-05 13:21:50 +01:00
Preston Timmons 23c4cbc0fa Cleaned up formatting in template_tests.test_custom. 2015-02-04 09:47:24 -05:00
darkryder 9ec8aa5e5d Fixed #24149 -- Normalized tuple settings to lists. 2015-02-03 14:59:45 -05:00
Preston Timmons cd4282816d Fixed #18651 -- Enabled optional assignments for simple_tag(). 2015-02-03 10:44:33 -05:00
Aymeric Augustin 2133f3157e Fixed #24168 -- Allowed selecting a template engine in a few APIs.
Specifically in rendering shortcuts, template responses, and class-based
views that return template responses.

Also added a test for render_to_response(status=...) which was missing
from fdbfc980.

Thanks Tim and Carl for the review.
2015-02-03 08:29:45 +01:00
Tim Graham b84100e8e2 Removed usage of deprecated removetags in a template test. 2015-01-18 18:32:47 -05:00
Tim Graham bd93032191 Removed ssi/url tags from future per deprecation timeline; refs #21939. 2015-01-17 13:29:52 -05:00
Aymeric Augustin 79deb6a071 Accounted for multiple template engines in template responses. 2015-01-12 21:01:34 +01:00
Aymeric Augustin a3e783fe11 Deprecated passing a Context to a generic Template.render.
A deprecation path is required because the return type of
django.template.loader.get_template changed during the
multiple template engines refactor.

test_csrf_token_in_404 was incorrect: it tested the case when the
hardcoded template was rendered, and that template doesn't depend on the
CSRF token. This commit makes it test the case when a custom template is
rendered.
2015-01-12 21:01:34 +01:00
Tim Graham 9f51d0c86d Fixed test from refs #23913 when running tests in reverse. 2015-01-12 13:20:44 -05:00
Ola Sitarska d563e3be68 Fixed #23913 -- Deprecated the `=` comparison in `if` template tag. 2015-01-11 15:21:01 -05:00
Preston Timmons 665e0aa6ec Fixed #24094 -- Enabled template tests to run individually. 2015-01-09 11:43:59 -05:00
Preston Timmons de9ebdd39c Fixed #24022 -- Deprecated the ssi tag. 2015-01-05 19:35:02 -05:00
Claude Paroz 51890ce889 Applied ignore_warnings to Django tests 2014-12-30 18:16:25 +01:00
Aymeric Augustin 9eb4f28e89 Deprecated TEMPLATE_CONTEXT_PROCESSORS. 2014-12-28 17:02:31 +01:00
Aymeric Augustin d3205e3e2e Deprecated TEMPLATE_DIRS. 2014-12-28 17:02:30 +01:00
Aymeric Augustin cf0fd65ed4 Deprecated TEMPLATE_LOADERS. 2014-12-28 17:02:30 +01:00
Aymeric Augustin d3a982556d Deprecated TEMPLATE_STRING_IF_INVALID. 2014-12-28 17:02:30 +01:00
Aymeric Augustin 3dc01aaaaf Deprecated ALLOWED_INCLUDE_ROOTS. 2014-12-28 17:02:30 +01:00
Aymeric Augustin cf1f36bb6e Deprecated current_app in TemplateResponse and render(_to_response). 2014-12-28 17:02:29 +01:00
Aymeric Augustin 90805b240f Supported multiple template engines in render_to_string.
Adjusted its API through a deprecation path according to the DEP.
2014-12-28 16:23:02 +01:00
Aymeric Augustin 5523e4cdbb Removed private API find_template.
It wasn't documented and it wasn't used anywhere, except in a few tests
that don't test it specifically and can be rewritten with get_template.
2014-12-28 16:23:01 +01:00
Aymeric Augustin 4ea43ac915 Supported multiple template engines in get_template and select_template.
This commit changes the return type of these two functions. Instead of
returning a django.template.Template they return a backend-specific
Template class that must implement render(self, context).
2014-12-28 16:23:01 +01:00
Aymeric Augustin 92a2d049a2 Isolated template tests from Django settings. 2014-12-28 16:23:01 +01:00
Aymeric Augustin 7eefdbf7ab Cleaned up the django.template namespace.
Since this package is going to hold both the implementation of the Django
Template Language and the infrastructure for Multiple Template Engines,
it should be untied from the DTL as much as possible within our
backwards-compatibility policy.

Only public APIs (i.e. APIs mentioned in the documentation) were left.
2014-12-28 14:47:31 +01:00
Preston Timmons f91d7366e0 Fixed #16028 -- Moved defaultfilters tests into template_tests. 2014-12-16 14:45:19 -05:00
Aymeric Augustin 71a559e771 Removed obsolete code for running test_loaders.py.
Running this file as a standalone script doesn't work anyway.
2014-12-13 22:51:57 +01:00
Tim Graham 3bb52c5019 Refs #23890 -- Restored silencing of numpy DeprecationWarnings in template tests. 2014-12-06 11:27:15 -05:00
Preston Timmons 5c68870169 Fixed #23958 -- Rewrote filter tests as unit tests. 2014-12-06 10:57:46 -05:00
Ramiro Morales 16f26defa7 Converted recently refactored templates tests to SimpleTestCase.
These test methods don't need DB setup/teardown.

Refs #23768 and b872134b.
2014-12-03 18:56:46 -05:00
Berker Peksag 560b4207b1 Removed redundant numbered parameters from str.format().
Since Python 2.7 and 3.1, "{0} {1}" is equivalent to "{} {}".
2014-12-03 14:27:38 -05:00
Berker Peksag adacbd64a0 Fixed "no such test method" error in template_tests.
Without this patch, you couldn't run an individual test
case in template_tests.

Refs #23768
2014-12-03 13:04:23 +01:00
Preston Timmons b872134bfc Fixed #23768 -- Rewrote template tests as unit tests. 2014-12-02 19:18:35 -05:00
Baptiste Mispelon c335c0fee9 Fixed #23914 -- Improved {% now %} to allow storing its result in the context.
Thanks to Tim for the review.
2014-11-25 22:11:35 +01:00