From 18f42a0edf0fa70d281afe1369dcfd45ee535915 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 9 Sep 2020 17:21:16 +0200 Subject: [PATCH] flows/importer: fix multiple uses of an importer instance causing errors --- passbook/flows/transfer/importer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/passbook/flows/transfer/importer.py b/passbook/flows/transfer/importer.py index a3239f771..9c03023d9 100644 --- a/passbook/flows/transfer/importer.py +++ b/passbook/flows/transfer/importer.py @@ -1,4 +1,5 @@ """Flow importer""" +from copy import deepcopy from json import loads from typing import Any, Dict @@ -130,7 +131,8 @@ class FlowImporter: def _apply_models(self) -> bool: """Apply (create/update) flow json""" self.__pk_map = {} - for entry in self.__import.entries: + entries = deepcopy(self.__import.entries) + for entry in entries: model_app_label, model_name = entry.model.split(".") model: SerializerModel = apps.get_model(model_app_label, model_name) # Validate each single entry