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
d481890c
Commit
d481890c
authored
Nov 27, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #121. Fixed detection of implicit joins
parent
1d73974e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
view.py
flask_admin/contrib/sqlamodel/view.py
+12
-3
tools.py
flask_admin/tools.py
+0
-1
No files found.
flask_admin/contrib/sqlamodel/view.py
View file @
d481890c
...
...
@@ -327,6 +327,9 @@ class ModelView(BaseModelView):
return
attr
.
property
.
columns
def
_need_join
(
self
,
table
):
return
table
not
in
self
.
model
.
_sa_class_manager
.
mapper
.
tables
def
init_search
(
self
):
"""
Initialize search. Returns `True` if search is supported for this
...
...
@@ -350,7 +353,7 @@ class ModelView(BaseModelView):
self
.
_search_fields
.
append
(
column
)
# If it belongs to different table - add a join
if
column
.
table
!=
self
.
model
.
__table__
:
if
self
.
_need_join
(
column
.
table
)
:
self
.
_search_joins
[
column
.
table
.
name
]
=
column
.
table
return
bool
(
self
.
column_searchable_list
)
...
...
@@ -397,7 +400,9 @@ class ModelView(BaseModelView):
visible_name
)
if
flt
:
self
.
_filter_joins
[
column
.
table
.
name
]
=
column
.
table
if
self
.
_need_join
(
column
.
table
):
self
.
_filter_joins
[
column
.
table
.
name
]
=
column
.
table
filters
.
extend
(
flt
)
return
filters
...
...
@@ -421,7 +426,7 @@ class ModelView(BaseModelView):
if
flt
:
# If there's relation to other table, do it
if
column
.
table
!=
self
.
model
.
__table__
:
if
self
.
_need_join
(
column
.
table
)
:
self
.
_filter_joins
[
column
.
table
.
name
]
=
column
.
table
return
flt
...
...
@@ -481,6 +486,10 @@ class ModelView(BaseModelView):
for
p
in
self
.
_get_model_iterator
():
if
hasattr
(
p
,
'direction'
):
# Check if it is pointing to same model
if
p
.
mapper
.
class_
==
self
.
model
:
continue
if
p
.
direction
.
name
==
'MANYTOONE'
:
relations
.
add
(
p
.
key
)
...
...
flask_admin/tools.py
View file @
d481890c
...
...
@@ -143,5 +143,4 @@ class ObsoleteAttr(object):
return
self
.
default
def
__set__
(
self
,
obj
,
value
):
print
'set'
,
self
.
new_name
,
value
,
self
.
cache
setattr
(
obj
,
self
.
cache
,
value
)
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