def migrate_cc_user(cls, doc):

        # skip if doesn't have location
        if not doc.get('location_id'):
            return

        # skip if already migrated
        if doc['location_id'] in doc.get('assigned_location_ids', []):
            user_data = doc.get('user_data', {})
            expected = user_location_data(doc['assigned_location_ids'])
            actual = user_data.get('commcare_location_ids', None)
            if expected == actual:
                return

        apply_migration(doc)
        apply_migration(doc['domain_membership'])
        if doc['assigned_location_ids']:
            doc['user_data'].update({
                'commcare_location_ids': user_location_data(doc['assigned_location_ids'])
            })
        return DocUpdate(doc)
Exemplo n.º 2
0
    def migrate_cc_user(cls, doc):

        # skip if doesn't have location
        if not doc.get('location_id'):
            return

        # skip if already migrated
        if doc['location_id'] in doc.get('assigned_location_ids', []):
            user_data = doc.get('user_data', {})
            expected = user_location_data(doc['assigned_location_ids'])
            actual = user_data.get('commcare_location_ids', None)
            if expected == actual:
                return

        apply_migration(doc)
        apply_migration(doc['domain_membership'])
        if doc['assigned_location_ids']:
            doc['user_data'].update({
                'commcare_location_ids': user_location_data(doc['assigned_location_ids'])
            })
        return DocUpdate(doc)