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
ab5824d1
Commit
ab5824d1
authored
Feb 06, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly resolve proxies/synonym properies in SQLa backend
parent
aafb9889
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
5 deletions
+18
-5
form.py
flask_admin/contrib/sqlamodel/form.py
+18
-5
No files found.
flask_admin/contrib/sqlamodel/form.py
View file @
ab5824d1
...
...
@@ -277,6 +277,20 @@ class AdminModelConverter(ModelConverterBase):
return
form
.
Select2TagsField
(
save_as_list
=
True
,
**
field_args
)
def
_resolve_prop
(
prop
):
"""
Resolve proxied property
:param prop:
Property to resolve
"""
# Try to see if it is proxied property
if
hasattr
(
prop
,
'_proxied_property'
):
return
prop
.
_proxied_property
return
prop
# Get list of fields and generate form
def
get_form
(
model
,
converter
,
base_class
=
form
.
BaseForm
,
...
...
@@ -320,11 +334,8 @@ def get_form(model, converter,
def
find
(
name
):
# Try to look it up in properties list first
p
=
props
.
get
(
name
)
if
p
is
not
None
:
# Try to see if it is proxied property
if
hasattr
(
p
,
'_proxied_property'
):
return
p
.
_proxied_property
if
p
is
not
None
:
return
p
# If it is hybrid property or alias, look it up in a model itself
...
...
@@ -340,11 +351,13 @@ def get_form(model, converter,
properties
=
(
x
for
x
in
properties
if
x
[
0
]
not
in
exclude
)
field_dict
=
{}
for
name
,
p
rop
in
properties
:
for
name
,
p
in
properties
:
# Ignore protected properties
if
ignore_hidden
and
name
.
startswith
(
'_'
):
continue
prop
=
_resolve_prop
(
p
)
field
=
converter
.
convert
(
model
,
mapper
,
prop
,
field_args
.
get
(
name
),
hidden_pk
)
if
field
is
not
None
:
field_dict
[
name
]
=
field
...
...
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