(self, domain, create_record=False)
If create_record is True, a DomainRemovalRecord is created so that the
        action can be undone, and the DomainRemovalRecord is returned.

        If create_record is True but the domain membership is not found,
        then None is returned.
If create_record is True, a DomainRemovalRecord is created so that the
        action can be undone, and the DomainRemovalRecord is returned.
If create_record is True a DomainRemovalRecord is created so that the action can be undone and the DomainRemovalRecord is returned .
def delete_domain_membership(self, domain, create_record=False):
        """
        If create_record is True, a DomainRemovalRecord is created so that the
        action can be undone, and the DomainRemovalRecord is returned.

        If create_record is True but the domain membership is not found,
        then None is returned.
        """
        self.get_by_user_id.clear(self.__class__, self.user_id, domain)
        record = None

        for i, dm in enumerate(self.domain_memberships):
            if dm.domain == domain:
                if create_record:
                    record = DomainRemovalRecord(
                        domain=domain,
                        user_id=self.user_id,
                        domain_membership=dm,
                    )
                del self.domain_memberships[i]
                break

        for i, domain_name in enumerate(self.domains):
            if domain_name == domain:
                del self.domains[i]
                break

        if record:
            record.save()
            return record
def delete_domain_membership ( self , domain , create_record = False ) : self . get_by_user_id . clear ( self . __class__ , self . user_id , domain ) record = None for i , dm in enumerate ( self . domain_memberships ) : if dm . domain == domain : if create_record : record = DomainRemovalRecord ( domain = domain , user_id = self . user_id , domain_membership = dm , ) del self . domain_memberships [ i ] break for i , domain_name in enumerate ( self . domains ) : if domain_name == domain : del self . domains [ i ] break if record : record . save ( ) return record