We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Inline datatables localization files to speed up first paint
Right now, datatables gets the localization file in form of a URL (see [datatables.html](https://github.com/fsr-itse/EvaP/blob/master/evap/evaluation/templates/datatables.html)), that is, it starts an ajax request when it starts processing the tables, and waits with processing until the result has been received.

both locales should be included into the compressed javascript or inlined into the html template so they are loaded earlier.

we do something similar for the [bootstrap datetimepicker](https://github.com/fsr-itse/EvaP/blob/028b6301e3eed446d93ae8675030d82c68d46886/evap/evaluation/templates/bootstrap_datetimepicker.html). unfortunately, it's not that easy in this case, since the localization files are json files, not javascript files.

one approach would be to turn the json files to js files, and simply putting the datastructure inside into a variable with the name of the corresponding locale.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `evap/evaluation/templatetags/evaluation_filters.py`
Content:
```
1 from collections import namedtuple
2 
3 from django.forms import TypedChoiceField
4 from django.template import Library
5 from django.utils.translation import ugettext_lazy as _
6 
7 from evap.evaluation.models import BASE_UNIPOLAR_CHOICES
8 from evap.rewards.tools import can_reward_points_be_used_by
9 from evap.student.forms import HeadingField
10 
11 
12 # the names displayed for contributors
13 STATE_NAMES = {
14     'new': _('new'),
15     'prepared': _('prepared'),
16     'editor_approved': _('editor approved'),
17     'approved': _('approved'),
18     'in_evaluation': _('in evaluation'),
19     'evaluated': _('evaluated'),
20     'reviewed': _('reviewed'),
21     'published': _('published'),
22 }
23 
24 
25 # the descriptions used in tooltips for contributors
26 STATE_DESCRIPTIONS = {
27     'new': _('The evaluation was newly created and will be prepared by the evaluation team.'),
28     'prepared': _('The evaluation was prepared by the evaluation team and is now available for editors.'),
29     'editor_approved': _('The evaluation was approved by an editor and will now be checked by the evaluation team.'),
30     'approved': _('All preparations are finished. The evaluation will begin once the defined start date is reached.'),
31     'in_evaluation': _('The evaluation is currently running until the defined end date is reached.'),
32     'evaluated': _('The evaluation has finished and will now be reviewed by the evaluation team.'),
33     'reviewed': _('The evaluation has finished and was reviewed by the evaluation team. You will receive an email when its results are published.'),
34     'published': _('The results for this evaluation have been published.'),
35 }
36 
37 
38 # values for approval states shown to staff
39 StateValues = namedtuple('StateValues', ('order', 'icon', 'filter', 'description'))
40 APPROVAL_STATES = {
41     'new': StateValues(0, 'fas fa-circle icon-yellow', 'fa-circle icon-yellow', _('In preparation')),
42     'prepared': StateValues(2, 'far fa-square icon-gray', 'fa-square icon-gray', _('Awaiting editor review')),
43     'editor_approved': StateValues(1, 'far fa-check-square icon-yellow', 'fa-check-square icon-yellow', _('Approved by editor, awaiting manager review')),
44     'approved': StateValues(3, 'far fa-check-square icon-green', 'fa-check-square icon-green', _('Approved by manager')),
45 }
46 
47 
48 register = Library()
49 
50 
51 @register.filter(name='zip')
52 def _zip(a, b):
53     return zip(a, b)
54 
55 
56 @register.filter()
57 def zip_choices(counts, choices):
58     return zip(counts, choices.names, choices.colors, choices.values)
59 
60 
61 @register.filter
62 def ordering_index(evaluation):
63     if evaluation.state in ['new', 'prepared', 'editor_approved', 'approved']:
64         return evaluation.days_until_evaluation
65     elif evaluation.state == "in_evaluation":
66         return 100000 + evaluation.days_left_for_evaluation
67     return 200000 + evaluation.days_left_for_evaluation
68 
69 
70 # from http://www.jongales.com/blog/2009/10/19/percentage-django-template-tag/
71 @register.filter
72 def percentage(fraction, population):
73     try:
74         return "{0:.0f}%".format(int(float(fraction) / float(population) * 100))
75     except ValueError:
76         return None
77     except ZeroDivisionError:
78         return None
79 
80 
81 @register.filter
82 def percentage_one_decimal(fraction, population):
83     try:
84         return "{0:.1f}%".format((float(fraction) / float(population)) * 100)
85     except ValueError:
86         return None
87     except ZeroDivisionError:
88         return None
89 
90 
91 @register.filter
92 def to_colors(choices):
93     if not choices:
94         # When displaying the course distribution, there are no associated voting choices.
95         # In that case, we just use the colors of a unipolar scale.
96         return BASE_UNIPOLAR_CHOICES['colors']
97     return choices.colors
98 
99 
100 @register.filter
101 def statename(state):
102     return STATE_NAMES.get(state)
103 
104 
105 @register.filter
106 def statedescription(state):
107     return STATE_DESCRIPTIONS.get(state)
108 
109 
110 @register.filter
111 def approval_state_values(state):
112     if state in APPROVAL_STATES:
113         return APPROVAL_STATES[state]
114     elif state in ['in_evaluation', 'evaluated', 'reviewed', 'published']:
115         return APPROVAL_STATES['approved']
116     return None
117 
118 
119 @register.filter
120 def approval_state_icon(state):
121     if state in APPROVAL_STATES:
122         return APPROVAL_STATES[state].icon
123     elif state in ['in_evaluation', 'evaluated', 'reviewed', 'published']:
124         return APPROVAL_STATES['approved'].icon
125     return None
126 
127 
128 @register.filter
129 def can_results_page_be_seen_by(evaluation, user):
130     return evaluation.can_results_page_be_seen_by(user)
131 
132 
133 @register.filter(name='can_reward_points_be_used_by')
134 def _can_reward_points_be_used_by(user):
135     return can_reward_points_be_used_by(user)
136 
137 
138 @register.filter
139 def is_choice_field(field):
140     return isinstance(field.field, TypedChoiceField)
141 
142 
143 @register.filter
144 def is_heading_field(field):
145     return isinstance(field.field, HeadingField)
146 
147 
148 @register.filter
149 def is_user_editor_or_delegate(evaluation, user):
150     return evaluation.is_user_editor_or_delegate(user)
151 
152 
153 @register.filter
154 def is_user_responsible_or_contributor_or_delegate(evaluation, user):
155     return evaluation.is_user_responsible_or_contributor_or_delegate(user)
156 
157 @register.filter
158 def message_class(level):
159     return {
160         'debug': 'info',
161         'info': 'info',
162         'success': 'success',
163         'warning': 'warning',
164         'error': 'danger',
165     }.get(level, 'info')
166 
167 
168 @register.filter
169 def hours_and_minutes(time_left_for_evaluation):
170     hours = time_left_for_evaluation.seconds // 3600
171     minutes = (time_left_for_evaluation.seconds // 60) % 60
172     return "{:02}:{:02}".format(hours, minutes)
173 
174 
175 @register.filter
176 def has_nonresponsible_editor(evaluation):
177     return evaluation.contributions.filter(can_edit=True).exclude(contributor__in=evaluation.course.responsibles.all()).exists()
178
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/evap/evaluation/templatetags/evaluation_filters.py b/evap/evaluation/templatetags/evaluation_filters.py
--- a/evap/evaluation/templatetags/evaluation_filters.py
+++ b/evap/evaluation/templatetags/evaluation_filters.py
@@ -38,10 +38,10 @@
 # values for approval states shown to staff
 StateValues = namedtuple('StateValues', ('order', 'icon', 'filter', 'description'))
 APPROVAL_STATES = {
-    'new': StateValues(0, 'fas fa-circle icon-yellow', 'fa-circle icon-yellow', _('In preparation')),
-    'prepared': StateValues(2, 'far fa-square icon-gray', 'fa-square icon-gray', _('Awaiting editor review')),
-    'editor_approved': StateValues(1, 'far fa-check-square icon-yellow', 'fa-check-square icon-yellow', _('Approved by editor, awaiting manager review')),
-    'approved': StateValues(3, 'far fa-check-square icon-green', 'fa-check-square icon-green', _('Approved by manager')),
+    'new': StateValues(0, 'fas fa-circle icon-yellow', 'new', _('In preparation')),
+    'prepared': StateValues(2, 'far fa-square icon-gray', 'prepared', _('Awaiting editor review')),
+    'editor_approved': StateValues(1, 'far fa-check-square icon-yellow', 'editor_approved', _('Approved by editor, awaiting manager review')),
+    'approved': StateValues(3, 'far fa-check-square icon-green', 'approved', _('Approved by manager')),
 }

{"golden_diff": "diff --git a/evap/evaluation/templatetags/evaluation_filters.py b/evap/evaluation/templatetags/evaluation_filters.py\n--- a/evap/evaluation/templatetags/evaluation_filters.py\n+++ b/evap/evaluation/templatetags/evaluation_filters.py\n@@ -38,10 +38,10 @@\n # values for approval states shown to staff\n StateValues = namedtuple('StateValues', ('order', 'icon', 'filter', 'description'))\n APPROVAL_STATES = {\n-    'new': StateValues(0, 'fas fa-circle icon-yellow', 'fa-circle icon-yellow', _('In preparation')),\n-    'prepared': StateValues(2, 'far fa-square icon-gray', 'fa-square icon-gray', _('Awaiting editor review')),\n-    'editor_approved': StateValues(1, 'far fa-check-square icon-yellow', 'fa-check-square icon-yellow', _('Approved by editor, awaiting manager review')),\n-    'approved': StateValues(3, 'far fa-check-square icon-green', 'fa-check-square icon-green', _('Approved by manager')),\n+    'new': StateValues(0, 'fas fa-circle icon-yellow', 'new', _('In preparation')),\n+    'prepared': StateValues(2, 'far fa-square icon-gray', 'prepared', _('Awaiting editor review')),\n+    'editor_approved': StateValues(1, 'far fa-check-square icon-yellow', 'editor_approved', _('Approved by editor, awaiting manager review')),\n+    'approved': StateValues(3, 'far fa-check-square icon-green', 'approved', _('Approved by manager')),\n }\n", "issue": "Inline datatables localization files to speed up first paint\nRight now, datatables gets the localization file in form of a URL (see [datatables.html](https://github.com/fsr-itse/EvaP/blob/master/evap/evaluation/templates/datatables.html)), that is, it starts an ajax request when it starts processing the tables, and waits with processing until the result has been received.\r\n\r\nboth locales should be included into the compressed javascript or inlined into the html template so they are loaded earlier.\r\n\r\nwe do something similar for the [bootstrap datetimepicker](https://github.com/fsr-itse/EvaP/blob/028b6301e3eed446d93ae8675030d82c68d46886/evap/evaluation/templates/bootstrap_datetimepicker.html). unfortunately, it's not that easy in this case, since the localization files are json files, not javascript files.\r\n\r\none approach would be to turn the json files to js files, and simply putting the datastructure inside into a variable with the name of the corresponding locale.\n", "before_files": [{"content": "from collections import namedtuple\n\nfrom django.forms import TypedChoiceField\nfrom django.template import Library\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom evap.evaluation.models import BASE_UNIPOLAR_CHOICES\nfrom evap.rewards.tools import can_reward_points_be_used_by\nfrom evap.student.forms import HeadingField\n\n\n# the names displayed for contributors\nSTATE_NAMES = {\n    'new': _('new'),\n    'prepared': _('prepared'),\n    'editor_approved': _('editor approved'),\n    'approved': _('approved'),\n    'in_evaluation': _('in evaluation'),\n    'evaluated': _('evaluated'),\n    'reviewed': _('reviewed'),\n    'published': _('published'),\n}\n\n\n# the descriptions used in tooltips for contributors\nSTATE_DESCRIPTIONS = {\n    'new': _('The evaluation was newly created and will be prepared by the evaluation team.'),\n    'prepared': _('The evaluation was prepared by the evaluation team and is now available for editors.'),\n    'editor_approved': _('The evaluation was approved by an editor and will now be checked by the evaluation team.'),\n    'approved': _('All preparations are finished. The evaluation will begin once the defined start date is reached.'),\n    'in_evaluation': _('The evaluation is currently running until the defined end date is reached.'),\n    'evaluated': _('The evaluation has finished and will now be reviewed by the evaluation team.'),\n    'reviewed': _('The evaluation has finished and was reviewed by the evaluation team. You will receive an email when its results are published.'),\n    'published': _('The results for this evaluation have been published.'),\n}\n\n\n# values for approval states shown to staff\nStateValues = namedtuple('StateValues', ('order', 'icon', 'filter', 'description'))\nAPPROVAL_STATES = {\n    'new': StateValues(0, 'fas fa-circle icon-yellow', 'fa-circle icon-yellow', _('In preparation')),\n    'prepared': StateValues(2, 'far fa-square icon-gray', 'fa-square icon-gray', _('Awaiting editor review')),\n    'editor_approved': StateValues(1, 'far fa-check-square icon-yellow', 'fa-check-square icon-yellow', _('Approved by editor, awaiting manager review')),\n    'approved': StateValues(3, 'far fa-check-square icon-green', 'fa-check-square icon-green', _('Approved by manager')),\n}\n\n\nregister = Library()\n\n\n@register.filter(name='zip')\ndef _zip(a, b):\n    return zip(a, b)\n\n\n@register.filter()\ndef zip_choices(counts, choices):\n    return zip(counts, choices.names, choices.colors, choices.values)\n\n\n@register.filter\ndef ordering_index(evaluation):\n    if evaluation.state in ['new', 'prepared', 'editor_approved', 'approved']:\n        return evaluation.days_until_evaluation\n    elif evaluation.state == \"in_evaluation\":\n        return 100000 + evaluation.days_left_for_evaluation\n    return 200000 + evaluation.days_left_for_evaluation\n\n\n# from http://www.jongales.com/blog/2009/10/19/percentage-django-template-tag/\n@register.filter\ndef percentage(fraction, population):\n    try:\n        return \"{0:.0f}%\".format(int(float(fraction) / float(population) * 100))\n    except ValueError:\n        return None\n    except ZeroDivisionError:\n        return None\n\n\n@register.filter\ndef percentage_one_decimal(fraction, population):\n    try:\n        return \"{0:.1f}%\".format((float(fraction) / float(population)) * 100)\n    except ValueError:\n        return None\n    except ZeroDivisionError:\n        return None\n\n\n@register.filter\ndef to_colors(choices):\n    if not choices:\n        # When displaying the course distribution, there are no associated voting choices.\n        # In that case, we just use the colors of a unipolar scale.\n        return BASE_UNIPOLAR_CHOICES['colors']\n    return choices.colors\n\n\n@register.filter\ndef statename(state):\n    return STATE_NAMES.get(state)\n\n\n@register.filter\ndef statedescription(state):\n    return STATE_DESCRIPTIONS.get(state)\n\n\n@register.filter\ndef approval_state_values(state):\n    if state in APPROVAL_STATES:\n        return APPROVAL_STATES[state]\n    elif state in ['in_evaluation', 'evaluated', 'reviewed', 'published']:\n        return APPROVAL_STATES['approved']\n    return None\n\n\n@register.filter\ndef approval_state_icon(state):\n    if state in APPROVAL_STATES:\n        return APPROVAL_STATES[state].icon\n    elif state in ['in_evaluation', 'evaluated', 'reviewed', 'published']:\n        return APPROVAL_STATES['approved'].icon\n    return None\n\n\n@register.filter\ndef can_results_page_be_seen_by(evaluation, user):\n    return evaluation.can_results_page_be_seen_by(user)\n\n\n@register.filter(name='can_reward_points_be_used_by')\ndef _can_reward_points_be_used_by(user):\n    return can_reward_points_be_used_by(user)\n\n\n@register.filter\ndef is_choice_field(field):\n    return isinstance(field.field, TypedChoiceField)\n\n\n@register.filter\ndef is_heading_field(field):\n    return isinstance(field.field, HeadingField)\n\n\n@register.filter\ndef is_user_editor_or_delegate(evaluation, user):\n    return evaluation.is_user_editor_or_delegate(user)\n\n\n@register.filter\ndef is_user_responsible_or_contributor_or_delegate(evaluation, user):\n    return evaluation.is_user_responsible_or_contributor_or_delegate(user)\n\n@register.filter\ndef message_class(level):\n    return {\n        'debug': 'info',\n        'info': 'info',\n        'success': 'success',\n        'warning': 'warning',\n        'error': 'danger',\n    }.get(level, 'info')\n\n\n@register.filter\ndef hours_and_minutes(time_left_for_evaluation):\n    hours = time_left_for_evaluation.seconds // 3600\n    minutes = (time_left_for_evaluation.seconds // 60) % 60\n    return \"{:02}:{:02}\".format(hours, minutes)\n\n\n@register.filter\ndef has_nonresponsible_editor(evaluation):\n    return evaluation.contributions.filter(can_edit=True).exclude(contributor__in=evaluation.course.responsibles.all()).exists()\n", "path": "evap/evaluation/templatetags/evaluation_filters.py"}], "after_files": [{"content": "from collections import namedtuple\n\nfrom django.forms import TypedChoiceField\nfrom django.template import Library\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom evap.evaluation.models import BASE_UNIPOLAR_CHOICES\nfrom evap.rewards.tools import can_reward_points_be_used_by\nfrom evap.student.forms import HeadingField\n\n\n# the names displayed for contributors\nSTATE_NAMES = {\n    'new': _('new'),\n    'prepared': _('prepared'),\n    'editor_approved': _('editor approved'),\n    'approved': _('approved'),\n    'in_evaluation': _('in evaluation'),\n    'evaluated': _('evaluated'),\n    'reviewed': _('reviewed'),\n    'published': _('published'),\n}\n\n\n# the descriptions used in tooltips for contributors\nSTATE_DESCRIPTIONS = {\n    'new': _('The evaluation was newly created and will be prepared by the evaluation team.'),\n    'prepared': _('The evaluation was prepared by the evaluation team and is now available for editors.'),\n    'editor_approved': _('The evaluation was approved by an editor and will now be checked by the evaluation team.'),\n    'approved': _('All preparations are finished. The evaluation will begin once the defined start date is reached.'),\n    'in_evaluation': _('The evaluation is currently running until the defined end date is reached.'),\n    'evaluated': _('The evaluation has finished and will now be reviewed by the evaluation team.'),\n    'reviewed': _('The evaluation has finished and was reviewed by the evaluation team. You will receive an email when its results are published.'),\n    'published': _('The results for this evaluation have been published.'),\n}\n\n\n# values for approval states shown to staff\nStateValues = namedtuple('StateValues', ('order', 'icon', 'filter', 'description'))\nAPPROVAL_STATES = {\n    'new': StateValues(0, 'fas fa-circle icon-yellow', 'new', _('In preparation')),\n    'prepared': StateValues(2, 'far fa-square icon-gray', 'prepared', _('Awaiting editor review')),\n    'editor_approved': StateValues(1, 'far fa-check-square icon-yellow', 'editor_approved', _('Approved by editor, awaiting manager review')),\n    'approved': StateValues(3, 'far fa-check-square icon-green', 'approved', _('Approved by manager')),\n}\n\n\nregister = Library()\n\n\n@register.filter(name='zip')\ndef _zip(a, b):\n    return zip(a, b)\n\n\n@register.filter()\ndef zip_choices(counts, choices):\n    return zip(counts, choices.names, choices.colors, choices.values)\n\n\n@register.filter\ndef ordering_index(evaluation):\n    if evaluation.state in ['new', 'prepared', 'editor_approved', 'approved']:\n        return evaluation.days_until_evaluation\n    elif evaluation.state == \"in_evaluation\":\n        return 100000 + evaluation.days_left_for_evaluation\n    return 200000 + evaluation.days_left_for_evaluation\n\n\n# from http://www.jongales.com/blog/2009/10/19/percentage-django-template-tag/\n@register.filter\ndef percentage(fraction, population):\n    try:\n        return \"{0:.0f}%\".format(int(float(fraction) / float(population) * 100))\n    except ValueError:\n        return None\n    except ZeroDivisionError:\n        return None\n\n\n@register.filter\ndef percentage_one_decimal(fraction, population):\n    try:\n        return \"{0:.1f}%\".format((float(fraction) / float(population)) * 100)\n    except ValueError:\n        return None\n    except ZeroDivisionError:\n        return None\n\n\n@register.filter\ndef to_colors(choices):\n    if not choices:\n        # When displaying the course distribution, there are no associated voting choices.\n        # In that case, we just use the colors of a unipolar scale.\n        return BASE_UNIPOLAR_CHOICES['colors']\n    return choices.colors\n\n\n@register.filter\ndef statename(state):\n    return STATE_NAMES.get(state)\n\n\n@register.filter\ndef statedescription(state):\n    return STATE_DESCRIPTIONS.get(state)\n\n\n@register.filter\ndef approval_state_values(state):\n    if state in APPROVAL_STATES:\n        return APPROVAL_STATES[state]\n    elif state in ['in_evaluation', 'evaluated', 'reviewed', 'published']:\n        return APPROVAL_STATES['approved']\n    return None\n\n\n@register.filter\ndef approval_state_icon(state):\n    if state in APPROVAL_STATES:\n        return APPROVAL_STATES[state].icon\n    elif state in ['in_evaluation', 'evaluated', 'reviewed', 'published']:\n        return APPROVAL_STATES['approved'].icon\n    return None\n\n\n@register.filter\ndef can_results_page_be_seen_by(evaluation, user):\n    return evaluation.can_results_page_be_seen_by(user)\n\n\n@register.filter(name='can_reward_points_be_used_by')\ndef _can_reward_points_be_used_by(user):\n    return can_reward_points_be_used_by(user)\n\n\n@register.filter\ndef is_choice_field(field):\n    return isinstance(field.field, TypedChoiceField)\n\n\n@register.filter\ndef is_heading_field(field):\n    return isinstance(field.field, HeadingField)\n\n\n@register.filter\ndef is_user_editor_or_delegate(evaluation, user):\n    return evaluation.is_user_editor_or_delegate(user)\n\n\n@register.filter\ndef is_user_responsible_or_contributor_or_delegate(evaluation, user):\n    return evaluation.is_user_responsible_or_contributor_or_delegate(user)\n\n@register.filter\ndef message_class(level):\n    return {\n        'debug': 'info',\n        'info': 'info',\n        'success': 'success',\n        'warning': 'warning',\n        'error': 'danger',\n    }.get(level, 'info')\n\n\n@register.filter\ndef hours_and_minutes(time_left_for_evaluation):\n    hours = time_left_for_evaluation.seconds // 3600\n    minutes = (time_left_for_evaluation.seconds // 60) % 60\n    return \"{:02}:{:02}\".format(hours, minutes)\n\n\n@register.filter\ndef has_nonresponsible_editor(evaluation):\n    return evaluation.contributions.filter(can_edit=True).exclude(contributor__in=evaluation.course.responsibles.all()).exists()\n", "path": "evap/evaluation/templatetags/evaluation_filters.py"}]}