(self, case_id, new_duplicate_case_ids)
return False
Handles existing duplicate objects.

        Returns True if there is nothing else to be done
Handles existing duplicate objects.
Handles existing duplicate objects .
def _handle_existing_duplicates(self, case_id, new_duplicate_case_ids):
        """Handles existing duplicate objects.

        Returns True if there is nothing else to be done
        """
        try:
            existing_duplicate_case_ids = set(
                CaseDuplicate.objects
                .prefetch_related('potential_duplicates')
                .get(action=self, case_id=case_id)
                .potential_duplicates
                .all()
                .values_list('case_id', flat=True)
            ) | set([case_id])  # The duplicates we currently have for this case tracked in the system
        except CaseDuplicate.DoesNotExist:
            # There are no duplicate cases currently in the system.
            # We continue on to create duplicates only if there are duplicates to create.
            return new_duplicate_case_ids == {case_id}

        if new_duplicate_case_ids == {case_id}:
            # This is no longer a duplicate, so check that there aren't any
            # other cases that are no longer duplicates
            CaseDuplicate.remove_unique_cases(action=self, case_id=case_id)
            CaseDuplicate.remove_duplicates_for_action(action=self, case_id=case_id)
            return True

        if new_duplicate_case_ids == existing_duplicate_case_ids:
            # If the list of duplicates hasn't changed, we don't need to do anything more
            return True

        # Delete all CaseDuplicates with this case_id, we'll recreate them later
        CaseDuplicate.remove_duplicates_for_action(action=self, case_id=case_id)
        return False
def _handle_existing_duplicates ( self , case_id , new_duplicate_case_ids ) : try : existing_duplicate_case_ids = set ( CaseDuplicate . objects . prefetch_related ( 'potential_duplicates' ) . get ( action = self , case_id = case_id ) . potential_duplicates . all ( ) . values_list ( 'case_id' , flat = True ) ) | set ( [ case_id ] ) # The duplicates we currently have for this case tracked in the system except CaseDuplicate . DoesNotExist : # There are no duplicate cases currently in the system. # We continue on to create duplicates only if there are duplicates to create. return new_duplicate_case_ids == { case_id } if new_duplicate_case_ids == { case_id } : # This is no longer a duplicate, so check that there aren't any # other cases that are no longer duplicates CaseDuplicate . remove_unique_cases ( action = self , case_id = case_id ) CaseDuplicate . remove_duplicates_for_action ( action = self , case_id = case_id ) return True if new_duplicate_case_ids == existing_duplicate_case_ids : # If the list of duplicates hasn't changed, we don't need to do anything more return True # Delete all CaseDuplicates with this case_id, we'll recreate them later CaseDuplicate . remove_duplicates_for_action ( action = self , case_id = case_id ) return False