Code

Ticket #15840: 15840.patch.3.diff

File 15840.patch.3.diff, 1.5 KB (added by zsiciarz, 2 years ago)

Improved the patch so it applies cleanly to current trunk. Only the condition decorator needs testing, as the other two are implemented in terms of it.

Line 
1diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py
2index 495a7b1..c282da5 100644
3--- a/django/views/decorators/http.py
4+++ b/django/views/decorators/http.py
5@@ -153,7 +153,7 @@ def condition(etag_func=None, last_modified_func=None):
6 
7             return response
8 
9-        return inner
10+        return wraps(func, assigned=available_attrs(func))(inner)
11     return decorator
12 
13 # Shortcut decorators for common cases based on ETag or Last-Modified only
14diff --git a/tests/regressiontests/decorators/tests.py b/tests/regressiontests/decorators/tests.py
15index 51f75d7..749df43 100644
16--- a/tests/regressiontests/decorators/tests.py
17+++ b/tests/regressiontests/decorators/tests.py
18@@ -11,7 +11,7 @@ from django.utils.functional import allow_lazy, lazy, memoize
19 from django.utils.unittest import TestCase
20 from django.views.decorators.cache import cache_page, never_cache, cache_control
21 from django.views.decorators.clickjacking import xframe_options_deny, xframe_options_sameorigin, xframe_options_exempt
22-from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe
23+from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe, condition
24 from django.views.decorators.vary import vary_on_headers, vary_on_cookie
25 
26 
27@@ -38,6 +38,7 @@ full_decorator = compose(
28     require_GET,
29     require_POST,
30     require_safe,
31+    condition(lambda r: None, lambda r: None),
32 
33     # django.views.decorators.vary
34     vary_on_headers('Accept-language'),