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
203291f7
Commit
203291f7
authored
Oct 23, 2018
by
PJ Janse van Rensburg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'handle-stale-sort-parameter'
parents
d6239512
55eca4e7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
6 deletions
+48
-6
changelog.rst
doc/changelog.rst
+8
-5
__init__.py
flask_admin/contrib/fileadmin/__init__.py
+5
-1
test_fileadmin.py
flask_admin/tests/fileadmin/test_fileadmin.py
+35
-0
No files found.
doc/changelog.rst
View file @
203291f7
...
@@ -6,15 +6,18 @@ next release
...
@@ -6,15 +6,18 @@ next release
* Support nested categories in the navbar menu
* Support nested categories in the navbar menu
* SQLAlchemy
* SQLAlchemy
* sort on multiple columns with `column_default_sort`
* sort on multiple columns with `column_default_sort`
* sort on related models in `column_sortable_list`
* sort on related models in `column_sortable_list`
* fix: inline model forms can now also be used for models with multiple primary keys
* fix: inline model forms can now also be used for models with multiple primary keys
* support for using mapped `column_property`
* support for using mapped `column_property`
* Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration
* Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration
* Specify `minimum_input_length` for ajax widget
* Specify `minimum_input_length` for ajax widget
* Peewee: support composite keys
* Peewee: support composite keys
* MongoEngine: when searching/filtering the input is now regarded as case-insensitive by default
* MongoEngine: when searching/filtering the input is now regarded as case-insensitive by default
* FileAdmin: handle special characters in filename + fix a bug with listing directories on Windows
* FileAdmin
* handle special characters in filename
* fix a bug with listing directories on Windows
* avoid raising an exception when unknown sort parameter is encountered
1.5.2
1.5.2
-----
-----
...
...
flask_admin/contrib/fileadmin/__init__.py
View file @
203291f7
...
@@ -844,6 +844,11 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -844,6 +844,11 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
self
.
default_desc
:
if
self
.
default_desc
:
sort_desc
=
self
.
default_desc
sort_desc
=
self
.
default_desc
try
:
column_index
=
self
.
possible_columns
.
index
(
sort_column
)
except
ValueError
:
sort_column
=
self
.
default_sort_column
if
sort_column
is
None
:
if
sort_column
is
None
:
# Sort by name
# Sort by name
items
.
sort
(
key
=
itemgetter
(
0
))
items
.
sort
(
key
=
itemgetter
(
0
))
...
@@ -853,7 +858,6 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -853,7 +858,6 @@ class BaseFileAdmin(BaseView, ActionsMixin):
# Sort by modified date
# Sort by modified date
items
.
sort
(
key
=
lambda
x
:
(
x
[
0
],
x
[
1
],
x
[
2
],
x
[
3
],
datetime
.
utcfromtimestamp
(
x
[
4
])),
reverse
=
True
)
items
.
sort
(
key
=
lambda
x
:
(
x
[
0
],
x
[
1
],
x
[
2
],
x
[
3
],
datetime
.
utcfromtimestamp
(
x
[
4
])),
reverse
=
True
)
else
:
else
:
column_index
=
self
.
possible_columns
.
index
(
sort_column
)
items
.
sort
(
key
=
itemgetter
(
column_index
),
reverse
=
sort_desc
)
items
.
sort
(
key
=
itemgetter
(
column_index
),
reverse
=
sort_desc
)
# Generate breadcrumbs
# Generate breadcrumbs
...
...
flask_admin/tests/fileadmin/test_fileadmin.py
View file @
203291f7
import
os
import
os.path
as
op
import
os.path
as
op
import
unittest
import
unittest
...
@@ -208,3 +209,37 @@ class LocalFileAdminTests(Base.FileAdminTests):
...
@@ -208,3 +209,37 @@ class LocalFileAdminTests(Base.FileAdminTests):
def
fileadmin_args
(
self
):
def
fileadmin_args
(
self
):
return
(
self
.
_test_files_root
,
'/files'
),
{}
return
(
self
.
_test_files_root
,
'/files'
),
{}
def
test_fileadmin_sort_bogus_url_param
(
self
):
fileadmin_class
=
self
.
fileadmin_class
()
fileadmin_args
,
fileadmin_kwargs
=
self
.
fileadmin_args
()
app
,
admin
=
setup
()
class
MyFileAdmin
(
fileadmin_class
):
editable_extensions
=
(
'txt'
,)
view_kwargs
=
dict
(
fileadmin_kwargs
)
view_kwargs
.
setdefault
(
'name'
,
'Files'
)
view
=
MyFileAdmin
(
*
fileadmin_args
,
**
view_kwargs
)
admin
.
add_view
(
view
)
client
=
app
.
test_client
()
with
open
(
op
.
join
(
self
.
_test_files_root
,
'dummy2.txt'
),
'w'
)
as
fp
:
# make sure that 'files/dummy2.txt' exists, is newest and has bigger size
fp
.
write
(
'test'
)
rv
=
client
.
get
(
'/admin/myfileadmin/?sort=bogus'
)
eq_
(
rv
.
status_code
,
200
)
ok_
(
rv
.
data
.
decode
(
'utf-8'
)
.
find
(
'path=dummy2.txt'
)
<
rv
.
data
.
decode
(
'utf-8'
)
.
find
(
'path=dummy.txt'
))
rv
=
client
.
get
(
'/admin/myfileadmin/?sort=name'
)
eq_
(
rv
.
status_code
,
200
)
ok_
(
rv
.
data
.
decode
(
'utf-8'
)
.
find
(
'path=dummy.txt'
)
<
rv
.
data
.
decode
(
'utf-8'
)
.
find
(
'path=dummy2.txt'
))
try
:
# clean up
os
.
remove
(
op
.
join
(
self
.
_test_files_root
,
'dummy2.txt'
))
except
(
IOError
,
OSError
):
pass
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