From 2996c9702f284fd428818f386666a42bade301c7 Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Mon, 25 May 2020 12:15:48 +0200 Subject: [PATCH] more cleaning --- management/commands/_import_utils.py | 3 +-- management/commands/import_account.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/management/commands/_import_utils.py b/management/commands/_import_utils.py index aad9b8e..3903820 100644 --- a/management/commands/_import_utils.py +++ b/management/commands/_import_utils.py @@ -82,13 +82,12 @@ class BulkCreateManager(object): model_key = model_class._meta.label # check for mutli-table inheritance it happens # if model_class is a grand-child of PolymorphicModel - if model_class.__base__ is not PolymorphicModel and model_class.__base__.__base__ is PolymorphicModel: + if model_class.__base__.__base__ is PolymorphicModel: self._commit(model_class.__base__) with transaction.atomic(): for obj in self._create_queues[model_key]: obj.save_base(raw=True) else: - # ensure that parents models exists model_class.objects.bulk_create(self._create_queues[model_key]) self._create_queues[model_key] = [] diff --git a/management/commands/import_account.py b/management/commands/import_account.py index 670f5b8..3a3fe11 100644 --- a/management/commands/import_account.py +++ b/management/commands/import_account.py @@ -176,10 +176,10 @@ class Command(ImportCommand): bulk_mgr = BulkCreateManager(chunk_size=chunk_size) pk_alias = Alias.objects.order_by('-id').first().id + 1 for idx, row in enumerate(cur): - self.update_line(idx, n, row["alias"]) alias_name = row["alias"] alias_name = (alias_name[:252] + '...') if len(alias_name) > 255 else alias_name alias_norm = Alias.normalize(alias_name) + self.update_line(idx, n, alias_norm) # clean pseudo (normalized pseudo must be unique) if alias_norm in ALIAS_SET: continue