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
d897c718
Commit
d897c718
authored
Sep 18, 2016
by
Serge S. Koval
Committed by
GitHub
Sep 18, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1348 from vToMy/bugfix/remote_hybrid_property
Added support for remote hybrid properties filters
parents
d7ee730a
8f7a35ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
tools.py
flask_admin/contrib/sqla/tools.py
+6
-7
view.py
flask_admin/contrib/sqla/view.py
+10
-1
No files found.
flask_admin/contrib/sqla/tools.py
View file @
d897c718
...
...
@@ -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 @
d897c718
...
...
@@ -2,6 +2,7 @@ import logging
import
warnings
import
inspect
from
speaklater
import
is_lazy_string
,
make_lazy_string
from
sqlalchemy.orm.attributes
import
InstrumentedAttribute
from
sqlalchemy.orm
import
joinedload
,
aliased
from
sqlalchemy.sql.expression
import
desc
...
...
@@ -617,6 +618,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 +638,14 @@ 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
)
column_name
=
self
.
get_column_name
(
name
)
def
prettify
():
return
column_name
.
replace
(
'.'
,
' / '
)
if
is_lazy_string
(
column_name
):
visible_name
=
make_lazy_string
(
prettify
)
else
:
visible_name
=
prettify
()
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