(self, location_ids, commit=True)
Reset user's assigned_locations to given location_ids and update user data.
            This should be called after updating primary location via set_location/unset_location
            If primary-location is not set, then next available location from
            assigned_location_ids is set as the primary-location
Reset user's assigned_locations to given location_ids and update user data.
            This should be called after updating primary location via set_location/unset_location
            If primary-location is not set, then next available location from
            assigned_location_ids is set as the primary-location
Reset user s assigned_locations to given location_ids and update user data . This should be called after updating primary location via set_location / unset_location If primary - location is not set then next available location from assigned_location_ids is set as the primary - location
def reset_locations(self, location_ids, commit=True):
        """
        Reset user's assigned_locations to given location_ids and update user data.
            This should be called after updating primary location via set_location/unset_location
            If primary-location is not set, then next available location from
            assigned_location_ids is set as the primary-location
        """
        from corehq.apps.locations.models import SQLLocation

        self.assigned_location_ids = location_ids
        self.get_domain_membership(self.domain).assigned_location_ids = location_ids
        if location_ids:
            self.update_metadata({
                'commcare_location_ids': user_location_data(location_ids)
            })
        else:
            self.pop_metadata('commcare_location_ids', None)

        # try to set primary-location if not set already
        if not self.location_id and location_ids:
            self.set_location(SQLLocation.objects.get(location_id=location_ids[0]), commit=False)

        if commit:
            self.save()
def reset_locations ( self , location_ids , commit = True ) : from corehq . apps . locations . models import SQLLocation self . assigned_location_ids = location_ids self . get_domain_membership ( self . domain ) . assigned_location_ids = location_ids if location_ids : self . update_metadata ( { 'commcare_location_ids' : user_location_data ( location_ids ) } ) else : self . pop_metadata ( 'commcare_location_ids' , None ) # try to set primary-location if not set already if not self . location_id and location_ids : self . set_location ( SQLLocation . objects . get ( location_id = location_ids [ 0 ] ) , commit = False ) if commit : self . save ( )