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
8679ea33
Commit
8679ea33
authored
Apr 04, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Filters for remote columns will work through explicitly specified foreign key.
parent
6a9f6312
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
simple.py
examples/sqla/simple.py
+1
-1
view.py
flask_adminex/ext/sqlamodel/view.py
+4
-3
No files found.
examples/sqla/simple.py
View file @
8679ea33
...
@@ -62,7 +62,7 @@ class PostAdmin(sqlamodel.ModelView):
...
@@ -62,7 +62,7 @@ class PostAdmin(sqlamodel.ModelView):
searchable_columns
=
(
'title'
,
User
.
username
)
searchable_columns
=
(
'title'
,
User
.
username
)
column_filters
=
(
User
,
column_filters
=
(
'user'
,
'title'
,
'title'
,
'date'
,
'date'
,
filters
.
FilterLike
(
Post
.
title
,
'Fixed Title'
,
options
=
((
'test1'
,
'Test 1'
),
(
'test2'
,
'Test 2'
))))
filters
.
FilterLike
(
Post
.
title
,
'Fixed Title'
,
options
=
((
'test1'
,
'Test 1'
),
(
'test2'
,
'Test 2'
))))
...
...
flask_adminex/ext/sqlamodel/view.py
View file @
8679ea33
from
sqlalchemy.orm.attributes
import
InstrumentedAttribute
from
sqlalchemy.orm.attributes
import
InstrumentedAttribute
from
sqlalchemy.orm
import
subqueryload
from
sqlalchemy.orm
import
subqueryload
from
sqlalchemy.sql.expression
import
desc
from
sqlalchemy.sql.expression
import
desc
...
@@ -280,10 +281,10 @@ class ModelView(BaseModelView):
...
@@ -280,10 +281,10 @@ class ModelView(BaseModelView):
if
attr
is
None
:
if
attr
is
None
:
raise
Exception
(
'Failed to find field for filter:
%
s'
%
name
)
raise
Exception
(
'Failed to find field for filter:
%
s'
%
name
)
if
hasattr
(
attr
,
'
_sa_class_manager
'
):
if
hasattr
(
attr
,
'
property'
)
and
hasattr
(
attr
.
property
,
'direction
'
):
filters
=
[]
filters
=
[]
for
p
in
self
.
_get_model_iterator
(
attr
):
for
p
in
self
.
_get_model_iterator
(
attr
.
property
.
mapper
.
class_
):
if
hasattr
(
p
,
'columns'
):
if
hasattr
(
p
,
'columns'
):
# TODO: Check for multiple columns
# TODO: Check for multiple columns
column
=
p
.
columns
[
0
]
column
=
p
.
columns
[
0
]
...
@@ -291,7 +292,7 @@ class ModelView(BaseModelView):
...
@@ -291,7 +292,7 @@ class ModelView(BaseModelView):
if
column
.
foreign_keys
or
column
.
primary_key
:
if
column
.
foreign_keys
or
column
.
primary_key
:
continue
continue
visible_name
=
'
%
s /
%
s'
%
(
self
.
get_column_name
(
attr
.
__table__
.
name
),
visible_name
=
'
%
s /
%
s'
%
(
self
.
get_column_name
(
attr
.
prop
.
table
.
name
),
self
.
get_column_name
(
p
.
key
))
self
.
get_column_name
(
p
.
key
))
type_name
=
type
(
column
.
type
)
.
__name__
type_name
=
type
(
column
.
type
)
.
__name__
...
...
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