strasbourg: add prefilling based on user profile
This commit is contained in:
parent
711300dbc8
commit
aa49b947cf
|
@ -57,6 +57,20 @@ field_id = 1
|
|||
|
||||
first_fieldset = True
|
||||
|
||||
|
||||
prefill = {
|
||||
'_title': ['Civilité'],
|
||||
'_first_name': ['Prénom'],
|
||||
'_last_name': ['Nom'],
|
||||
'_email': ['Courriel', 'Adresse e-mail', 'Adresse courriel', 'Adresse mail'],
|
||||
'_zipcode': ['Code postal'],
|
||||
'_city': ['Commune', 'Ville'],
|
||||
'_phone': ['Téléphone'],
|
||||
'_mobile': ['Téléphone mobile'],
|
||||
}
|
||||
prefill_used = {}
|
||||
|
||||
|
||||
def process_children(node):
|
||||
global field_id, first_fieldset
|
||||
|
||||
|
@ -165,6 +179,14 @@ def process_children(node):
|
|||
value = field_node.find('value')
|
||||
if value is not None and value.text:
|
||||
field.prefill = {'type': 'string', 'value': fix_encoding(value.text)}
|
||||
else:
|
||||
# prefill with user profile?
|
||||
for key, field_names in prefill.items():
|
||||
if key in prefill_used:
|
||||
continue
|
||||
if field.label in field_names:
|
||||
field.prefill = {'type': 'user', 'value': key}
|
||||
prefill_used[key] = True
|
||||
|
||||
process_children(root)
|
||||
|
||||
|
|
Loading…
Reference in New Issue