summarylogtreecommitdiffstats
path: root/new_jinja2_2.patch
blob: ddf2d402439ddc1f9e0f52991fd0b514aac57657 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
diff -ruN pkg/cms-germany-git/usr/lib/python3.10/site-packages/cms/server/jinja2_toolbox.py /usr/lib/python3.10/site-packages/cms/server/jinja2_toolbox.py
--- pkg/cms-germany-git/usr/lib/python3.10/site-packages/cms/server/jinja2_toolbox.py	2023-02-03 16:35:06.000000000 +0100
+++ /usr/lib/python3.10/site-packages/cms/server/jinja2_toolbox.py	2023-02-03 17:20:15.062792373 +0100
@@ -24,8 +24,7 @@
 
 """
 
-from jinja2 import Environment, StrictUndefined, contextfilter, \
-    contextfunction, environmentfunction
+from jinja2 import Environment, StrictUndefined, pass_context, pass_environment
 
 from cms import TOKEN_MODE_DISABLED, TOKEN_MODE_FINITE, TOKEN_MODE_INFINITE, \
     TOKEN_MODE_MIXED, FEEDBACK_LEVEL_FULL, FEEDBACK_LEVEL_RESTRICTED
@@ -40,7 +39,7 @@
     get_icon_for_type
 
 
-@contextfilter
+@pass_context
 def all_(ctx, l, test=None, *args):
     """Check if all elements of the given list pass the given test.
 
@@ -64,7 +63,7 @@
     return True
 
 
-@contextfilter
+@pass_context
 def any_(ctx, l, test=None, *args):
     """Check if any element of the given list passes the given test.
 
@@ -88,7 +87,7 @@
     return False
 
 
-@contextfilter
+@pass_context
 def dictselect(ctx, d, test=None, *args, by="key"):
     """Filter the given dict: keep only items that pass the given test.
 
@@ -115,7 +114,7 @@
                 if ctx.call(test, {"key": k, "value": v}[by], *args))
 
 
-@contextfunction
+@pass_context
 def today(ctx, dt):
     """Returns whether the given datetime is today.
 
@@ -165,7 +164,7 @@
     env.tests["is_unit_test"] = lambda s: s.is_unit_test()
 
 
-@environmentfunction
+@pass_environment
 def safe_get_task_type(env, *, dataset):
     try:
         return dataset.task_type_object
@@ -175,7 +174,7 @@
         return env.undefined("TaskType not found: %s" % err)
 
 
-@environmentfunction
+@pass_environment
 def safe_get_score_type(env, *, dataset):
     try:
         return dataset.score_type_object
@@ -196,21 +195,21 @@
     env.filters["to_language"] = get_language
 
 
-@contextfilter
+@pass_context
 def format_datetime(ctx, dt):
     translation = ctx.get("translation", DEFAULT_TRANSLATION)
     timezone = ctx.get("timezone", local_tz)
     return translation.format_datetime(dt, timezone)
 
 
-@contextfilter
+@pass_context
 def format_time(ctx, dt):
     translation = ctx.get("translation", DEFAULT_TRANSLATION)
     timezone = ctx.get("timezone", local_tz)
     return translation.format_time(dt, timezone)
 
 
-@contextfilter
+@pass_context
 def format_datetime_smart(ctx, dt):
     translation = ctx.get("translation", DEFAULT_TRANSLATION)
     now = ctx.get("now", make_datetime())
@@ -218,37 +217,37 @@
     return translation.format_datetime_smart(dt, now, timezone)
 
 
-@contextfilter
+@pass_context
 def format_timedelta(ctx, td):
     translation = ctx.get("translation", DEFAULT_TRANSLATION)
     return translation.format_timedelta(td)
 
 
-@contextfilter
+@pass_context
 def format_duration(ctx, d, length="short"):
     translation = ctx.get("translation", DEFAULT_TRANSLATION)
     return translation.format_duration(d, length)
 
 
-@contextfilter
+@pass_context
 def format_size(ctx, s):
     translation = ctx.get("translation", DEFAULT_TRANSLATION)
     return translation.format_size(s)
 
 
-@contextfilter
+@pass_context
 def format_decimal(ctx, n):
     translation = ctx.get("translation", DEFAULT_TRANSLATION)
     return translation.format_decimal(n)
 
 
-@contextfilter
+@pass_context
 def format_locale(ctx, n):
     translation = ctx.get("translation", DEFAULT_TRANSLATION)
     return translation.format_locale(n)
 
 
-@contextfilter
+@pass_context
 def wrapped_format_status_text(ctx, status_text):
     translation = ctx.get("translation", DEFAULT_TRANSLATION)
     return format_status_text(status_text, translation=translation)