(self)
Mark a location and its descendants as archived and unassigns users
        assigned to the location.
Mark a location and its descendants as archived and unassigns users
        assigned to the location.
Mark a location and its descendants as archived and unassigns users assigned to the location .
def archive(self):
        """
        Mark a location and its descendants as archived and unassigns users
        assigned to the location.
        """
        from .tasks import update_users_at_locations
        locations = self.get_descendants(include_self=True)
        for loc in locations:
            loc.is_archived = True
            loc.archived_on = datetime.utcnow()
            loc.save()
            loc._remove_user()

        update_users_at_locations.delay(
            self.domain,
            [loc.location_id for loc in locations],
            [loc.supply_point_id for loc in locations if loc.supply_point_id],
            list(self.get_ancestors().location_ids()),
        )
def archive ( self ) : from . tasks import update_users_at_locations locations = self . get_descendants ( include_self = True ) for loc in locations : loc . is_archived = True loc . archived_on = datetime . utcnow ( ) loc . save ( ) loc . _remove_user ( ) update_users_at_locations . delay ( self . domain , [ loc . location_id for loc in locations ] , [ loc . supply_point_id for loc in locations if loc . supply_point_id ] , list ( self . get_ancestors ( ) . location_ids ( ) ) , )