コード例 #1
0
ファイル: models.py プロジェクト: nnestle/commcare-hq
    def delete(self):
        from corehq.apps.domain.signals import commcare_domain_pre_delete

        results = commcare_domain_pre_delete.send_robust(sender='domain', domain=self)
        for result in results:
            if result[1]:
                raise DomainDeleteException(
                    u"Error occurred during domain pre_delete {}: {}".format(self.name, str(result[1]))
                )
        # delete all associated objects
        for db, related_doc_ids in get_all_doc_ids_for_domain_grouped_by_db(self.name):
            iter_bulk_delete(db, related_doc_ids, chunksize=500)
        self._delete_web_users_from_domain()
        self._delete_sql_objects()
        super(Domain, self).delete()
        Domain.get_by_name.clear(Domain, self.name)  # clear the domain cache
コード例 #2
0
    def _pre_delete(self):
        from corehq.apps.domain.signals import commcare_domain_pre_delete
        from corehq.apps.domain.deletion import apply_deletion_operations

        dynamic_deletion_operations = []
        results = commcare_domain_pre_delete.send_robust(sender='domain', domain=self)
        for result in results:
            response = result[1]
            if isinstance(response, Exception):
                raise DomainDeleteException(u"Error occurred during domain pre_delete {}: {}".format(self.name, str(response)))
            elif response:
                assert isinstance(response, list)
                dynamic_deletion_operations.extend(response)

        # delete all associated objects
        for db, related_doc_ids in get_all_doc_ids_for_domain_grouped_by_db(self.name):
            iter_bulk_delete(db, related_doc_ids, chunksize=500)

        apply_deletion_operations(self.name, dynamic_deletion_operations)
コード例 #3
0
    def _pre_delete(self):
        from corehq.apps.domain.signals import commcare_domain_pre_delete
        from corehq.apps.domain.deletion import apply_deletion_operations

        dynamic_deletion_operations = []
        results = commcare_domain_pre_delete.send_robust(sender='domain', domain=self)
        for result in results:
            response = result[1]
            if isinstance(response, Exception):
                raise DomainDeleteException(u"Error occurred during domain pre_delete {}: {}".format(self.name, str(response)))
            elif response:
                assert isinstance(response, list)
                dynamic_deletion_operations.extend(response)

        # delete all associated objects
        for db, related_doc_ids in get_all_doc_ids_for_domain_grouped_by_db(self.name):
            iter_bulk_delete(db, related_doc_ids, chunksize=500)

        apply_deletion_operations(self.name, dynamic_deletion_operations)