(loc_type_data, loc_type_db)
Store the sync expansion boundaries along with the location type. i.e. where
        the user's locations start expanding from, and where they expand to
Store the sync expansion boundaries along with the location type. i.e. where
        the user's locations start expanding from, and where they expand to
Store the sync expansion boundaries along with the location type . i . e . where the user s locations start expanding from and where they expand to
def _attach_sync_boundaries_to_location_type(loc_type_data, loc_type_db):
        """Store the sync expansion boundaries along with the location type. i.e. where
        the user's locations start expanding from, and where they expand to

        """
        loc_type = loc_type_db[loc_type_data['pk']]
        expand_from_id = loc_type_data['expand_from']
        expand_to_id = loc_type_data['expand_to']
        include_without_expanding_id = loc_type_data['include_without_expanding']
        include_only_ids = loc_type_data['include_only']
        try:
            loc_type.expand_from = loc_type_db[expand_from_id] if expand_from_id else None
        except KeyError:        # expand_from location type was deleted
            loc_type.expand_from = None
        loc_type.expand_from_root = loc_type_data['expand_from_root']
        try:
            loc_type.expand_to = loc_type_db[expand_to_id] if expand_to_id else None
        except KeyError:        # expand_to location type was deleted
            loc_type.expand_to = None
        try:
            loc_type.include_without_expanding = (loc_type_db[include_without_expanding_id]
                                                  if include_without_expanding_id else None)
        except KeyError:        # include_without_expanding location type was deleted
            loc_type.include_without_expanding = None
        include_only = LocationTypesView._get_include_only(include_only_ids, loc_type_db)
        loc_type.include_only.set(include_only)
        loc_type.save()
def _attach_sync_boundaries_to_location_type ( loc_type_data , loc_type_db ) : loc_type = loc_type_db [ loc_type_data [ 'pk' ] ] expand_from_id = loc_type_data [ 'expand_from' ] expand_to_id = loc_type_data [ 'expand_to' ] include_without_expanding_id = loc_type_data [ 'include_without_expanding' ] include_only_ids = loc_type_data [ 'include_only' ] try : loc_type . expand_from = loc_type_db [ expand_from_id ] if expand_from_id else None except KeyError : # expand_from location type was deleted loc_type . expand_from = None loc_type . expand_from_root = loc_type_data [ 'expand_from_root' ] try : loc_type . expand_to = loc_type_db [ expand_to_id ] if expand_to_id else None except KeyError : # expand_to location type was deleted loc_type . expand_to = None try : loc_type . include_without_expanding = ( loc_type_db [ include_without_expanding_id ] if include_without_expanding_id else None ) except KeyError : # include_without_expanding location type was deleted loc_type . include_without_expanding = None include_only = LocationTypesView . _get_include_only ( include_only_ids , loc_type_db ) loc_type . include_only . set ( include_only ) loc_type . save ( )