mirror of https://github.com/django/django.git
[4.2.x] Fixed #34286 -- Fixed admindocs markups for case-sensitive template/view names.
Backport of 1250483ebf
from main
This commit is contained in:
parent
0b6797eedd
commit
db0e10c037
1
AUTHORS
1
AUTHORS
|
@ -808,6 +808,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
Radek Švarz <https://www.svarz.cz/translate/>
|
Radek Švarz <https://www.svarz.cz/translate/>
|
||||||
Rafael Giebisch <rafael@giebisch-mail.de>
|
Rafael Giebisch <rafael@giebisch-mail.de>
|
||||||
Raffaele Salmaso <raffaele@salmaso.org>
|
Raffaele Salmaso <raffaele@salmaso.org>
|
||||||
|
Rahmat Faisal <mad.skidipap@gmail.com>
|
||||||
Rajesh Dhawan <rajesh.dhawan@gmail.com>
|
Rajesh Dhawan <rajesh.dhawan@gmail.com>
|
||||||
Ramez Ashraf <ramezashraf@gmail.com>
|
Ramez Ashraf <ramezashraf@gmail.com>
|
||||||
Ramil Yanbulatov <rayman1104@gmail.com>
|
Ramil Yanbulatov <rayman1104@gmail.com>
|
||||||
|
|
|
@ -101,6 +101,9 @@ ROLES = {
|
||||||
|
|
||||||
|
|
||||||
def create_reference_role(rolename, urlbase):
|
def create_reference_role(rolename, urlbase):
|
||||||
|
# Views and template names are case-sensitive.
|
||||||
|
is_case_sensitive = rolename in ["template", "view"]
|
||||||
|
|
||||||
def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
|
def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
|
||||||
if options is None:
|
if options is None:
|
||||||
options = {}
|
options = {}
|
||||||
|
@ -111,7 +114,7 @@ def create_reference_role(rolename, urlbase):
|
||||||
urlbase
|
urlbase
|
||||||
% (
|
% (
|
||||||
inliner.document.settings.link_base,
|
inliner.document.settings.link_base,
|
||||||
text.lower(),
|
text if is_case_sensitive else text.lower(),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
**options,
|
**options,
|
||||||
|
|
|
@ -104,6 +104,22 @@ class TestUtils(AdminDocsSimpleTestCase):
|
||||||
self.assertEqual(parse_rst(body, ""), "<p>second line</p>\n")
|
self.assertEqual(parse_rst(body, ""), "<p>second line</p>\n")
|
||||||
self.assertEqual(stderr.getvalue(), "")
|
self.assertEqual(stderr.getvalue(), "")
|
||||||
|
|
||||||
|
def test_parse_rst_view_case_sensitive(self):
|
||||||
|
source = ":view:`myapp.views.Index`"
|
||||||
|
rendered = (
|
||||||
|
'<p><a class="reference external" '
|
||||||
|
'href="/admindocs/views/myapp.views.Index/">myapp.views.Index</a></p>'
|
||||||
|
)
|
||||||
|
self.assertHTMLEqual(parse_rst(source, "view"), rendered)
|
||||||
|
|
||||||
|
def test_parse_rst_template_case_sensitive(self):
|
||||||
|
source = ":template:`Index.html`"
|
||||||
|
rendered = (
|
||||||
|
'<p><a class="reference external" href="/admindocs/templates/Index.html/">'
|
||||||
|
"Index.html</a></p>"
|
||||||
|
)
|
||||||
|
self.assertHTMLEqual(parse_rst(source, "template"), rendered)
|
||||||
|
|
||||||
def test_publish_parts(self):
|
def test_publish_parts(self):
|
||||||
"""
|
"""
|
||||||
Django shouldn't break the default role for interpreted text
|
Django shouldn't break the default role for interpreted text
|
||||||
|
|
Loading…
Reference in New Issue