Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
662c0703
Unverified
Commit
662c0703
authored
Aug 27, 2018
by
Serge S. Koval
Committed by
GitHub
Aug 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1496 from hadleyrich/master
Fix sorting in subdirectories in fileadmin
parents
2100cef8
710bb4f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
+16
-7
__init__.py
flask_admin/contrib/fileadmin/__init__.py
+11
-2
list.html
flask_admin/templates/bootstrap2/admin/file/list.html
+2
-2
list.html
flask_admin/templates/bootstrap3/admin/file/list.html
+3
-3
No files found.
flask_admin/contrib/fileadmin/__init__.py
View file @
662c0703
...
...
@@ -821,6 +821,12 @@ class BaseFileAdmin(BaseView, ActionsMixin):
sort_column
=
request
.
args
.
get
(
'sort'
,
None
,
type
=
str
)
sort_desc
=
request
.
args
.
get
(
'desc'
,
0
,
type
=
int
)
if
sort_column
is
None
:
if
self
.
default_sort_column
:
sort_column
=
self
.
default_sort_column
if
self
.
default_desc
:
sort_desc
=
self
.
default_desc
if
sort_column
is
None
:
# Sort by name
items
.
sort
(
key
=
itemgetter
(
0
))
...
...
@@ -842,13 +848,16 @@ class BaseFileAdmin(BaseView, ActionsMixin):
else
:
action_form
=
None
def
sort_url
(
column
,
invert
=
False
):
def
sort_url
(
column
,
path
,
invert
=
False
):
desc
=
None
if
not
path
:
path
=
None
if
invert
and
not
sort_desc
:
desc
=
1
return
self
.
get_url
(
'.index_view'
,
sort
=
column
,
desc
=
desc
)
return
self
.
get_url
(
'.index_view'
,
path
=
path
,
sort
=
column
,
desc
=
desc
)
return
self
.
render
(
self
.
list_template
,
dir_path
=
path
,
...
...
flask_admin/templates/bootstrap2/admin/file/list.html
View file @
662c0703
...
...
@@ -37,7 +37,7 @@
<th>
{% if admin_view.is_column_sortable(column) %}
{% if sort_column == column %}
<a
href=
"{{ sort_url(column, True) }}"
title=
"{{ _gettext('Sort by %(name)s', name=column) }}"
>
<a
href=
"{{ sort_url(column,
dir_path,
True) }}"
title=
"{{ _gettext('Sort by %(name)s', name=column) }}"
>
{{ admin_view.column_label(column) }}
{% if sort_desc %}
<i
class=
"fa fa-chevron-up icon-chevron-up"
></i>
...
...
@@ -46,7 +46,7 @@
{% endif %}
</a>
{% else %}
<a
href=
"{{ sort_url(column) }}"
title=
"{{ _gettext('Sort by %(name)s', name=column) }}"
>
{{ admin_view.column_label(column) }}
</a>
<a
href=
"{{ sort_url(column
, dir_path
) }}"
title=
"{{ _gettext('Sort by %(name)s', name=column) }}"
>
{{ admin_view.column_label(column) }}
</a>
{% endif %}
{% else %}
{{ _gettext(admin_view.column_label(column)) }}
...
...
flask_admin/templates/bootstrap3/admin/file/list.html
View file @
662c0703
...
...
@@ -37,7 +37,7 @@
<th>
{% if admin_view.is_column_sortable(column) %}
{% if sort_column == column %}
<a
href=
"{{ sort_url(column, True) }}"
title=
"{{ _gettext('Sort by %(name)s', name=column) }}"
>
<a
href=
"{{ sort_url(column,
dir_path,
True) }}"
title=
"{{ _gettext('Sort by %(name)s', name=column) }}"
>
{{ admin_view.column_label(column) }}
{% if sort_desc %}
<span
class=
"fa fa-chevron-up glyphicon glyphicon-chevron-up"
></span>
...
...
@@ -46,7 +46,7 @@
{% endif %}
</a>
{% else %}
<a
href=
"{{ sort_url(column) }}"
title=
"{{ _gettext('Sort by %(name)s', name=column) }}"
>
{{ admin_view.column_label(column) }}
</a>
<a
href=
"{{ sort_url(column
, dir_path
) }}"
title=
"{{ _gettext('Sort by %(name)s', name=column) }}"
>
{{ admin_view.column_label(column) }}
</a>
{% endif %}
{% else %}
{{ _gettext(admin_view.column_label(column)) }}
...
...
@@ -126,12 +126,12 @@
{{ size|filesizeformat }}
</td>
{% endif %}
{% endif %}
{% if admin_view.is_column_visible('date') %}
<td>
{{ timestamp_format(date) }}
</td>
{% endif %}
{% endif %}
{% endblock %}
</tr>
{% endfor %}
...
...
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