Skip to content

Commit 16e02f5

Browse files
committed
Rework the alerts panel to be compatible with serialization.
The alerts panel may eventually have other types of alerts that don't depend on the response. Such as Django's check system.
1 parent dd53424 commit 16e02f5

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

debug_toolbar/panels/alerts.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,9 @@ def check_invalid_file_form_configuration(self, html_content):
139139
return self.alerts
140140

141141
def generate_stats(self, request, response):
142-
if not is_processable_html_response(response):
143-
return
144-
145-
html_content = response.content.decode(response.charset)
146-
self.check_invalid_file_form_configuration(html_content)
142+
if is_processable_html_response(response):
143+
html_content = response.content.decode(response.charset)
144+
self.check_invalid_file_form_configuration(html_content)
147145

148146
# Further alert checks can go here
149147

tests/panels/test_alerts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ def _render():
109109
response = StreamingHttpResponse(_render())
110110

111111
self.panel.generate_stats(self.request, response)
112-
self.assertEqual(self.panel.get_stats(), {})
112+
self.assertEqual(self.panel.get_stats(), {"alerts": []})

0 commit comments

Comments
 (0)