utils: allow referencing a sub object of user_info in attribute mapping
This commit is contained in:
parent
d5c76ccee0
commit
9f3ec479ad
|
@ -55,11 +55,20 @@ def get_mapped_attributes_flat(request):
|
|||
return values
|
||||
|
||||
|
||||
def get_ref(ref, user_info):
|
||||
if not hasattr(user_info, 'iteritems'):
|
||||
return None
|
||||
if '.' in ref:
|
||||
left, right = ref.split('.', 1)
|
||||
return get_ref(right, user_info.get(left, {}))
|
||||
return user_info.get(ref)
|
||||
|
||||
|
||||
def mapping_to_value(mapping, user_info):
|
||||
if isinstance(mapping, basestring):
|
||||
value = user_info[mapping]
|
||||
value = get_ref(mapping, user_info)
|
||||
elif 'ref' in mapping:
|
||||
value = user_info[mapping['ref']]
|
||||
value = get_ref(mapping['ref'], user_info)
|
||||
elif 'value' in mapping:
|
||||
value = mapping['value']
|
||||
elif 'compute' in mapping:
|
||||
|
|
Loading…
Reference in New Issue