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
47080aeb
Commit
47080aeb
authored
Sep 15, 2016
by
Tom Kedem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for remote hybrid properties filters.
parent
d7ee730a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
tools.py
flask_admin/contrib/sqla/tools.py
+6
-7
view.py
flask_admin/contrib/sqla/view.py
+3
-1
No files found.
flask_admin/contrib/sqla/tools.py
View file @
47080aeb
...
...
@@ -190,7 +190,12 @@ def get_hybrid_properties(model):
def
is_hybrid_property
(
model
,
attr_name
):
return
attr_name
in
get_hybrid_properties
(
model
)
names
=
attr_name
.
split
(
'.'
)
last_model
=
model
for
i
in
range
(
len
(
names
)
-
1
):
last_model
=
getattr
(
last_model
,
names
[
i
])
.
property
.
argument
last_name
=
names
[
-
1
]
return
last_name
in
get_hybrid_properties
(
last_model
)
def
is_relationship
(
attr
):
...
...
@@ -199,9 +204,3 @@ def is_relationship(attr):
def
is_association_proxy
(
attr
):
return
hasattr
(
attr
,
'extension_type'
)
and
attr
.
extension_type
==
ASSOCIATION_PROXY
def
get_association_proxy_column_name
(
attr
):
# TODO find a better way to get the name
name
,
=
[
key
for
key
,
value
in
inspect
(
attr
.
owning_class
)
.
all_orm_descriptors
.
items
()
if
value
is
attr
]
return
name
flask_admin/contrib/sqla/view.py
View file @
47080aeb
...
...
@@ -617,6 +617,7 @@ class ModelView(BaseModelView):
is_hybrid_property
=
tools
.
is_hybrid_property
(
self
.
model
,
name
)
if
is_hybrid_property
:
column
=
attr
column
.
key
=
name
.
split
(
'.'
)[
-
1
]
else
:
columns
=
tools
.
get_columns_for_field
(
attr
)
...
...
@@ -636,7 +637,8 @@ class ModelView(BaseModelView):
if
not
isinstance
(
name
,
string_types
):
visible_name
=
self
.
get_column_name
(
name
.
property
.
key
)
else
:
visible_name
=
self
.
get_column_name
(
name
)
names
=
name
.
split
(
'.'
)
visible_name
=
' / '
.
join
([
self
.
get_column_name
(
names_item
)
for
names_item
in
names
])
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