소스 검색

Use double-quotes in modal_workflow responses for JSON-consistency

Matt Westcott 6 년 전
부모
커밋
87c247faa1
2개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 2
      wagtail/admin/modal_workflow.py
  2. 4 4
      wagtail/admin/tests/test_page_chooser.py

+ 2 - 2
wagtail/admin/modal_workflow.py

@@ -13,11 +13,11 @@ def render_modal_workflow(request, html_template, js_template, template_vars=Non
 
     if html_template:
         html = render_to_string(html_template, template_vars or {}, request=request)
-        response_keyvars.append("'html': %s" % json.dumps(html))
+        response_keyvars.append('"html": %s' % json.dumps(html))
 
     if js_template:
         js = render_to_string(js_template, template_vars or {}, request=request)
-        response_keyvars.append("'onload': %s" % js)
+        response_keyvars.append('"onload": %s' % js)
 
     if json_data:
         for key, val in json_data.items():

+ 4 - 4
wagtail/admin/tests/test_page_chooser.py

@@ -467,7 +467,7 @@ class TestChooserExternalLink(TestCase, WagtailTestUtils):
     def test_create_link(self):
         response = self.post({'url': 'http://www.example.com/', 'link_text': 'example'})
         self.assertEqual(response.status_code, 200)
-        self.assertContains(response, "'onload'")  # indicates success / post back to calling page
+        self.assertContains(response, '"onload"')  # indicates success / post back to calling page
         self.assertContains(response, '"url": "http://www.example.com/"')
         self.assertContains(response, '"title": "example"')  # When link text is given, it is used
         self.assertContains(response, '"prefer_this_title_as_link_text": true')
@@ -475,7 +475,7 @@ class TestChooserExternalLink(TestCase, WagtailTestUtils):
     def test_create_link_without_text(self):
         response = self.post({'url': 'http://www.example.com/'})
         self.assertEqual(response.status_code, 200)
-        self.assertContains(response, "'onload'")  # indicates success / post back to calling page
+        self.assertContains(response, '"onload"')  # indicates success / post back to calling page
         self.assertContains(response, '"url": "http://www.example.com/"')
         self.assertContains(response, '"title": "http://www.example.com/"')  # When no text is given, it uses the url
         self.assertContains(response, '"prefer_this_title_as_link_text": false')
@@ -502,13 +502,13 @@ class TestChooserExternalLink(TestCase, WagtailTestUtils):
     def test_invalid_url(self):
         response = self.post({'url': 'ntp://www.example.com', 'link_text': 'example'})
         self.assertEqual(response.status_code, 200)
-        self.assertContains(response, "'html'")  # indicates failure / show error message
+        self.assertContains(response, '"html"')  # indicates failure / show error message
         self.assertContains(response, "Enter a valid URL.")
 
     def test_allow_local_url(self):
         response = self.post({'url': '/admin/', 'link_text': 'admin'})
         self.assertEqual(response.status_code, 200)
-        self.assertContains(response, "'onload'")  # indicates success / post back to calling page
+        self.assertContains(response, '"onload"')  # indicates success / post back to calling page
         self.assertContains(response, '"url": "/admin/"')
         self.assertContains(response, '"title": "admin"')