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
23a8c6aa
Unverified
Commit
23a8c6aa
authored
May 25, 2018
by
Serge S. Koval
Committed by
GitHub
May 25, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1648 from tandreas/fix_different_bind_joins
Fix scaffold_auto_joins for differnet binds.
parents
745620ad
92f077e0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
view.py
flask_admin/contrib/sqla/view.py
+6
-0
test_basic.py
flask_admin/tests/sqla/test_basic.py
+28
-0
No files found.
flask_admin/contrib/sqla/view.py
View file @
23a8c6aa
...
...
@@ -765,6 +765,12 @@ class ModelView(BaseModelView):
if
p
.
mapper
.
class_
==
self
.
model
:
continue
# Check if it is pointing to a differnet bind
source_bind
=
getattr
(
self
.
model
,
'__bind_key__'
,
None
)
target_bind
=
getattr
(
p
.
mapper
.
class_
,
'__bind_key__'
,
None
)
if
source_bind
!=
target_bind
:
continue
if
p
.
direction
.
name
in
[
'MANYTOONE'
,
'MANYTOMANY'
]:
relations
.
add
(
p
.
key
)
...
...
flask_admin/tests/sqla/test_basic.py
View file @
23a8c6aa
...
...
@@ -2218,6 +2218,34 @@ def test_multipath_joins():
eq_
(
rv
.
status_code
,
200
)
def
test_different_bind_joins
():
app
,
db
,
admin
=
setup
()
app
.
config
[
'SQLALCHEMY_BINDS'
]
=
{
'other'
:
'sqlite:///'
}
class
Model1
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
val1
=
db
.
Column
(
db
.
String
(
20
))
class
Model2
(
db
.
Model
):
__bind_key__
=
'other'
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
val1
=
db
.
Column
(
db
.
String
(
20
))
first_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
Model1
.
id
))
first
=
db
.
relationship
(
Model1
)
db
.
create_all
()
view
=
CustomModelView
(
Model2
,
db
.
session
)
admin
.
add_view
(
view
)
client
=
app
.
test_client
()
rv
=
client
.
get
(
'/admin/model2/'
)
eq_
(
rv
.
status_code
,
200
)
def
test_model_default
():
app
,
db
,
admin
=
setup
()
_
,
Model2
=
create_models
(
db
)
...
...
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