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
a919e892
Commit
a919e892
authored
Aug 05, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor SQLa model_form refactoring
parent
c2c09b7f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
40 deletions
+43
-40
form.py
flask_admin/contrib/sqla/form.py
+43
-40
No files found.
flask_admin/contrib/sqla/form.py
View file @
a919e892
...
...
@@ -69,21 +69,7 @@ class AdminModelConverter(ModelConverterBase):
return
None
def
convert
(
self
,
model
,
mapper
,
prop
,
field_args
,
hidden_pk
):
# Properly handle forced fields
if
isinstance
(
prop
,
FieldPlaceholder
):
return
form
.
recreate_field
(
prop
.
field
)
kwargs
=
{
'validators'
:
[],
'filters'
:
[]
}
if
field_args
:
kwargs
.
update
(
field_args
)
# Check if it is relation or property
if
hasattr
(
prop
,
'direction'
):
def
_convert_relation
(
self
,
prop
,
kwargs
):
remote_model
=
prop
.
mapper
.
class_
local_column
=
prop
.
local_remote_pairs
[
0
][
0
]
...
...
@@ -124,6 +110,23 @@ class AdminModelConverter(ModelConverterBase):
return
QuerySelectMultipleField
(
**
kwargs
)
elif
prop
.
direction
.
name
==
'MANYTOMANY'
:
return
QuerySelectMultipleField
(
**
kwargs
)
def
convert
(
self
,
model
,
mapper
,
prop
,
field_args
,
hidden_pk
):
# Properly handle forced fields
if
isinstance
(
prop
,
FieldPlaceholder
):
return
form
.
recreate_field
(
prop
.
field
)
kwargs
=
{
'validators'
:
[],
'filters'
:
[]
}
if
field_args
:
kwargs
.
update
(
field_args
)
# Check if it is relation or property
if
hasattr
(
prop
,
'direction'
):
return
self
.
_convert_relation
(
prop
,
kwargs
)
else
:
# Ignore pk/fk
if
hasattr
(
prop
,
'columns'
):
...
...
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