Beispiel #1
0
 def _call_fut(self, d):
     from mnemos.utils import inv_dict
     return inv_dict(d)
Beispiel #2
0
    return attrs


COMPOSITE_LABELS = {'name': _('Name'),
                    'full_address': _('Address'),
                    'birthdate': _('Birthdate')}
COMPOSITES = {'last_name': 'name',
              'first_name': 'name',
              'address': 'full_address',
              'postal_code': 'full_address',
              'city': 'full_address',
              'country': 'full_address',
              'birth_day': 'birthdate',
              'birth_month': 'birthdate',
              'birth_year': 'birthdate'}
COMPOSITES_INV = inv_dict(COMPOSITES)


def _replace_by_composites(attributes):
    attrs = []
    for attr in attributes:
        composite = COMPOSITES.get(attr['name'])
        if composite is None:
            attrs.append(attr)
        else:
            composite = {'name': composite,
                         'label': COMPOSITE_LABELS[composite]}
            if composite not in attrs:
                attrs.append(composite)
    return attrs