Commit ab5824d1 authored by Serge S. Koval's avatar Serge S. Koval

Properly resolve proxies/synonym properies in SQLa backend

parent aafb9889
......@@ -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, prop 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment