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
26b12141
Commit
26b12141
authored
Dec 15, 2013
by
Bryan Hoyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make filters_by_group an ordered dict so that they appear in predictable order in the menu.
parent
cd3a3117
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
5 deletions
+29
-5
base.py
flask_admin/model/base.py
+29
-4
filters.js
flask_admin/static/admin/js/filters.js
+0
-1
No files found.
flask_admin/model/base.py
View file @
26b12141
...
@@ -18,6 +18,25 @@ from .helpers import prettify_name, get_mdict_item_or_list
...
@@ -18,6 +18,25 @@ from .helpers import prettify_name, get_mdict_item_or_list
from
.ajax
import
AjaxModelLoader
from
.ajax
import
AjaxModelLoader
try
:
from
collections
import
OrderedDict
except
ImportError
:
# Bare-bones OrderedDict implementation for Python2.6 compatibility
class
OrderedDict
(
dict
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
dict
.
__init__
(
self
,
*
args
,
**
kwargs
)
self
.
ordered_keys
=
[]
def
__setitem__
(
self
,
key
,
value
):
self
.
ordered_keys
.
append
(
key
)
dict
.
__setitem__
(
self
,
key
,
value
)
def
__iter__
(
self
):
return
(
k
for
k
in
self
.
ordered_keys
)
def
iteritems
(
self
):
return
((
k
,
self
[
k
])
for
k
in
self
.
ordered_keys
)
def
items
(
self
):
return
list
(
self
.
iteritems
())
class
BaseModelView
(
BaseView
,
ActionsMixin
):
class
BaseModelView
(
BaseView
,
ActionsMixin
):
"""
"""
Base model view.
Base model view.
...
@@ -258,7 +277,10 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -258,7 +277,10 @@ class BaseModelView(BaseView, ActionsMixin):
False by default so as to be robust across translations.
False by default so as to be robust across translations.
If you override unique_filter_label(), this has no effect.
Changing this parameter will break any existing URLs.
Override unique_filter_label() if you want to change the default format
of filter urls. This parameter only controls the default method.
"""
"""
column_display_pk
=
ObsoleteAttr
(
'column_display_pk'
,
column_display_pk
=
ObsoleteAttr
(
'column_display_pk'
,
...
@@ -553,7 +575,7 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -553,7 +575,7 @@ class BaseModelView(BaseView, ActionsMixin):
self
.
column_descriptions
=
dict
()
self
.
column_descriptions
=
dict
()
if
self
.
_filters
:
if
self
.
_filters
:
self
.
_flattened_filters_by_group
=
{}
self
.
_flattened_filters_by_group
=
OrderedDict
()
for
flt
in
self
.
_filters
:
for
flt
in
self
.
_filters
:
if
flt
.
name
not
in
self
.
_flattened_filters_by_group
:
if
flt
.
name
not
in
self
.
_flattened_filters_by_group
:
...
@@ -958,11 +980,14 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -958,11 +980,14 @@ class BaseModelView(BaseView, ActionsMixin):
By default, returns a numeric index or a human-readable filter name
By default, returns a numeric index or a human-readable filter name
Does not include the `flt[n]_` portion of the filter name.
Does not include the `flt[n]_` portion of the filter name.
To use custom names, override this function, eg
To use custom names, override this function, eg
`def unique_filter_label(self, flt): return flt.__class__.__name__`
def unique_filter_label(self, flt):
return flt.name + flt.__class__.__name__
Be aware that if you override this method, the default URL format
will no longer work.
"""
"""
if
self
.
named_filter_urls
:
if
self
.
named_filter_urls
:
return
u'{name}_{operation}'
.
format
(
name
=
flt
.
name
,
operation
=
flt
.
operation
())
.
lower
()
.
replace
(
' '
,
'_'
)
return
u'{name}_{operation}'
.
format
(
name
=
flt
.
name
,
operation
=
flt
.
operation
())
.
lower
()
.
replace
(
' '
,
'_'
)
...
...
flask_admin/static/admin/js/filters.js
View file @
26b12141
...
@@ -42,7 +42,6 @@ var AdminFilters = function(element, filters_element, filters_by_group) {
...
@@ -42,7 +42,6 @@ var AdminFilters = function(element, filters_element, filters_by_group) {
.
change
(
changeOperation
);
.
change
(
changeOperation
);
$
(
subfilters
).
each
(
function
()
{
$
(
subfilters
).
each
(
function
()
{
console
.
log
(
this
);
$select
.
append
(
$
(
'<option/>'
).
attr
(
'value'
,
this
.
label
).
text
(
this
.
operation
));
$select
.
append
(
$
(
'<option/>'
).
attr
(
'value'
,
this
.
label
).
text
(
this
.
operation
));
});
});
...
...
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