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
92f077e0
Commit
92f077e0
authored
May 25, 2018
by
Trevor Andreas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix scaffold_auto_joins for differnet binds.
parent
745620ad
Changes
2
Hide 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 @
92f077e0
...
@@ -765,6 +765,12 @@ class ModelView(BaseModelView):
...
@@ -765,6 +765,12 @@ class ModelView(BaseModelView):
if
p
.
mapper
.
class_
==
self
.
model
:
if
p
.
mapper
.
class_
==
self
.
model
:
continue
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'
]:
if
p
.
direction
.
name
in
[
'MANYTOONE'
,
'MANYTOMANY'
]:
relations
.
add
(
p
.
key
)
relations
.
add
(
p
.
key
)
...
...
flask_admin/tests/sqla/test_basic.py
View file @
92f077e0
...
@@ -2218,6 +2218,34 @@ def test_multipath_joins():
...
@@ -2218,6 +2218,34 @@ def test_multipath_joins():
eq_
(
rv
.
status_code
,
200
)
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
():
def
test_model_default
():
app
,
db
,
admin
=
setup
()
app
,
db
,
admin
=
setup
()
_
,
Model2
=
create_models
(
db
)
_
,
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