Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use correct language in panels (#1717)
* Use correct language in panels PR #1703 introduced a bug where SQLPanel (and probably others) is rendered in `LANGUAGE_CODE` language, while it should use `TOOLBAR_LANGUAGE` if provided. This PR fixes panel's content language. * Add missing changelog entries * Use code formatting and include more details on the recent change. * Create decorator to use TOOLBAR_LANGUAGE in toolbar specific views. This reviews the third-party panel documentation to reference these two decorators and explain them. They aren't necessary but should be used. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tim Schilling <schillingt@better-simple.com> Co-authored-by: Matthias Kestenholz <mk@feinheit.ch>
- Loading branch information
1 parent
145b112
commit da88665
Showing
10 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from unittest.mock import patch | ||
|
||
from django.http import HttpResponse | ||
from django.test import RequestFactory, TestCase | ||
from django.test.utils import override_settings | ||
|
||
from debug_toolbar.decorators import render_with_toolbar_language | ||
|
||
|
||
@render_with_toolbar_language | ||
def stub_view(request): | ||
return HttpResponse(200) | ||
|
||
|
||
@override_settings(DEBUG=True, LANGUAGE_CODE="fr") | ||
class RenderWithToolbarLanguageTestCase(TestCase): | ||
@override_settings(DEBUG_TOOLBAR_CONFIG={"TOOLBAR_LANGUAGE": "de"}) | ||
@patch("debug_toolbar.decorators.language_override") | ||
def test_uses_toolbar_language(self, mock_language_override): | ||
stub_view(RequestFactory().get("/")) | ||
mock_language_override.assert_called_once_with("de") | ||
|
||
@patch("debug_toolbar.decorators.language_override") | ||
def test_defaults_to_django_language_code(self, mock_language_override): | ||
stub_view(RequestFactory().get("/")) | ||
mock_language_override.assert_called_once_with("fr") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters