Skip to content

Commit

Permalink
fix: Patch Toolbar Middleware Response (django-cms#7856)
Browse files Browse the repository at this point in the history
* feat: new tests to validate response type depending on CMS_TOOLBAR_HIDE

* feat: return correct type from __call__ as defined by django
  • Loading branch information
jimlind authored Mar 28, 2024
1 parent ab17db0 commit 5fe8855
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cms/middleware/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, get_response):
def __call__(self, request):

if not self.is_cms_request(request):
return
return self.get_response(request)

edit_on = get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON')
edit_off = get_cms_setting('CMS_TOOLBAR_URL__EDIT_OFF')
Expand Down
10 changes: 10 additions & 0 deletions cms/tests/test_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ def test_cms_internal_ips_iptools_bad_range(self):
request = self.get_page_request(None, self.get_staff(), '/en/example/')
self.assertFalse(hasattr(request, 'toolbar'))

@override_settings(CMS_TOOLBAR_HIDE=True)
def test_correct_response_type_returned_hiding_toolbar(self):
response = self.client.post('/')
self.assertIsInstance(response, HttpResponse)

@override_settings(CMS_TOOLBAR_HIDE=False)
def test_correct_response_type_returned_showing_toolbar(self):
response = self.client.post('/')
self.assertIsInstance(response, HttpResponse)


@override_settings(CMS_PERMISSION=False)
class ToolbarTests(ToolbarTestBase):
Expand Down

0 comments on commit 5fe8855

Please sign in to comment.