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
25bb3b15
Commit
25bb3b15
authored
Jun 03, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use chevron control for row linking, rather than hyperlinking first item
parent
90f2e266
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
rest_framework/renderers.py
+0
-2
rest_framework/templates/rest_framework/admin/list.html
+3
-3
rest_framework/templatetags/rest_framework.py
+3
-1
No files found.
rest_framework/renderers.py
View file @
25bb3b15
...
...
@@ -730,12 +730,10 @@ class AdminRenderer(BrowsableAPIRenderer):
columns
=
[
key
for
key
in
header
.
keys
()
if
key
!=
'url'
]
details
=
[
key
for
key
in
header
.
keys
()
if
key
!=
'url'
]
linked
=
[
columns
[
0
]]
if
columns
else
[]
context
[
'style'
]
=
style
context
[
'columns'
]
=
columns
context
[
'details'
]
=
details
context
[
'linked'
]
=
linked
context
[
'results'
]
=
results
return
context
...
...
rest_framework/templates/rest_framework/admin/list.html
View file @
25bb3b15
{% load rest_framework %}
<table
class=
"table table-striped"
>
<thead>
<tr>
{% for column in columns%}
<th>
{{ column|capfirst }}
</th>
{% endfor %}
</tr>
<tr>
{% for column in columns%}
<th>
{{ column|capfirst }}
</th>
{% endfor %}
<
th></th><
/tr>
</thead>
<tbody>
{% for row in results %}
...
...
@@ -9,12 +9,12 @@
{% for key, value in row.items %}
{% if key in columns %}
<td
{{
value
|
add_nested_class
}}
>
{% if key in linked %}
<a
href=
"{{ row.url }}"
>
{% endif %}
{{ value|format_value }}
{% if key in linked %}
</a>
{% endif %}
</td>
{% endif %}
{% endfor %}
<td><a
href=
"{{ row.url }}"
><span
class=
"glyphicon glyphicon-chevron-right"
aria-hidden=
"true"
></span>
</a></td>
</tr>
{% endfor %}
</tbody>
...
...
rest_framework/templatetags/rest_framework.py
View file @
25bb3b15
...
...
@@ -134,7 +134,9 @@ def format_value(value):
@register.filter
def
add_nested_class
(
value
):
if
isinstance
(
value
,
(
list
,
dict
)):
if
isinstance
(
value
,
dict
):
return
'class=nested'
if
isinstance
(
value
,
list
)
and
any
([
isinstance
(
item
,
(
list
,
dict
))
for
item
in
value
]):
return
'class=nested'
return
''
...
...
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