Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
3d0292e1
Commit
3d0292e1
authored
Aug 14, 2015
by
Ollie Walsh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not ignore overridden View.get_view_name() in breadcrumbs
parent
1b53e804
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
rest_framework/utils/breadcrumbs.py
+1
-2
tests/test_utils.py
+16
-0
No files found.
rest_framework/utils/breadcrumbs.py
View file @
3d0292e1
...
...
@@ -32,8 +32,7 @@ def get_breadcrumbs(url, request=None):
# Don't list the same view twice in a row.
# Probably an optional trailing slash.
if
not
seen
or
seen
[
-
1
]
!=
view
:
suffix
=
getattr
(
view
,
'suffix'
,
None
)
name
=
view_name_func
(
cls
,
suffix
)
name
=
cls
()
.
get_view_name
()
insert_url
=
preserve_builtin_query_params
(
prefix
+
url
,
request
)
breadcrumbs_list
.
insert
(
0
,
(
name
,
insert_url
))
seen
.
append
(
view
)
...
...
tests/test_utils.py
View file @
3d0292e1
...
...
@@ -31,10 +31,15 @@ class NestedResourceRoot(APIView):
class
NestedResourceInstance
(
APIView
):
pass
class
CustomNameResourceInstance
(
APIView
):
def
get_view_name
(
self
):
return
"Foo"
urlpatterns
=
[
url
(
r'^$'
,
Root
.
as_view
()),
url
(
r'^resource/$'
,
ResourceRoot
.
as_view
()),
url
(
r'^resource/customname$'
,
CustomNameResourceInstance
.
as_view
()),
url
(
r'^resource/(?P<key>[0-9]+)$'
,
ResourceInstance
.
as_view
()),
url
(
r'^resource/(?P<key>[0-9]+)/$'
,
NestedResourceRoot
.
as_view
()),
url
(
r'^resource/(?P<key>[0-9]+)/(?P<other>[A-Za-z]+)$'
,
NestedResourceInstance
.
as_view
()),
...
...
@@ -75,6 +80,17 @@ class BreadcrumbTests(TestCase):
]
)
def
test_resource_instance_customname_breadcrumbs
(
self
):
url
=
'/resource/customname'
self
.
assertEqual
(
get_breadcrumbs
(
url
),
[
(
'Root'
,
'/'
),
(
'Resource Root'
,
'/resource/'
),
(
'Foo'
,
'/resource/customname'
)
]
)
def
test_nested_resource_breadcrumbs
(
self
):
url
=
'/resource/123/'
self
.
assertEqual
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment